GATE / CS ARCHIVE

GATE CSE 2005 / QUESTION 7

Computing transitive closure

Algorithms · Graph Algorithms · Full GATE CSE 2005 paper

GATE 2005, Q7 1 mark · MCQ
Report issue

Graph Algorithms

Question 7, GATE 2005: A known bound for computing transitive closure of an n-element relation is: A O(n); B O(n log n); C O(n^(3/2)); D O(n³).
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Warshall’s algorithm considers each possible intermediate vertex k and updates reachability R[i, j]←R[i, j]∨(R[i, k]∧R[k, j]) for every i, j. Its three nested loops take O(n³), D. Faster algebraic algorithms exist; the question asks a known upper bound, not a tight lower bound. The other listed bounds are subquadratic and cannot explicitly output every entry of an arbitrary n×n closure matrix.

Warshall’s algorithm loops over intermediate vertex k and every ordered pair(i, j), updating reachability using i→k→j. There are n choices in each loop, giving O(n³). This is a known upper bound, not a proof that faster algebraic methods are impossible. An explicitly written arbitrary n×n closure has quadratic output size, so the three listed subquadratic alternatives cannot generally output the full matrix.

Original paper, page 1