The time complexity of computing the transitive closure of binary relation on…
2018
The time complexity of computing the transitive closure of binary relation on a set of n elements is known to be
- A.
O(n)
- B.
O(n log n)
- C.
O(n 3/2)
- D.
O(n 3)
Attempted by 124 students.
Show answer & explanation
Correct answer: D
The transitive closure of a binary relation on a set of n elements represents all pairs (a, b) such that there is a path from a to b. The standard algorithm used to compute this efficiently is the Floyd-Warshall algorithm, which iteratively updates reachability between all pairs of vertices. This algorithm involves three nested loops iterating over the n elements, resulting in a time complexity of O(n³). While matrix multiplication-based approaches can theoretically achieve slightly better bounds like O(n^2.376), the classical and most commonly referenced complexity in standard computer science curricula remains O(n³). Option A (O(n)) and Option B (O(n log n)) are incorrect because they represent complexities for linear or near-linear operations, which are insufficient to process all possible pairs in a dense graph. Option C (O(n^1.5)) is also incorrect as it does not align with the standard cubic time requirement for exhaustive path checking in general graphs. Thus, Option D is the correct answer.
A video solution is available for this question — log in and enroll to watch it.