The Wayback Machine - https://web.archive.org/web/20240416003311/https://www.geeksforgeeks.org/gate-gate-cs-2005-question-7/
Open In App

GATE | GATE-CS-2005 | Question 7

Last Updated : 28 Jun, 2021
Like Article
Like
Save
Share
Report

The time complexity of computing the transitive closure of a binary relation on a set of n elements is known to be

(A)

O (n)

(B)

O (n log n)

(C)

O(n3/2)

(D)

O(n3)



Answer: (D)

Explanation:

Answer : (D)

Explanation:

The correct answer is (D), O(n3).

The transitive closure of a binary relation on a set of n elements can be computed using the Floyd–Warshall algorithm. This algorithm has a time complexity of O(n3).

The other options are incorrect. Option (A), O(n), is the time complexity of simply iterating over the set of n elements. Option (B), O(n log n), is the time complexity of sorting the set of n elements. Option (C), O(n3/2), is not a valid time complexity. https://www.geeksforgeeks.org/data-structures-and-algorithms-set-22/

See question 3 of

Quiz of this Question


Quiz of this Question
Please comment below if you find anything wrong in the above post


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads