The time complexity of computing the transitive closure of a binary relation on a set of n elements is
A
O(n)
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
O(nlogn)
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
O(n3/2)
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
O(n3)
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
Open in App
Solution
The correct option is DO(n3) The time complexity of computing the transitive closure of a binary relation on a set of n elements is O(n3). Apply the Warshall's algorithm to compute the transitive closure. The algorithm contains three nested for loops each having frequency n so time complexity is O(n3).