16 16 votes 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\log n)$ b. $O\left( n^{3/2}\right)$ c. $O( n^3 )$ d. $O(n)$ Algorithms isro2017 relations algorithms time-complexity + – sh!va 5.3k views answer comment Share Follow Print See 1 comment 1 1 comment reply Nirmal Gaur commented May 7, 2017 reply Follow flag Using Warshall's Algorithm: Transitive Closure we can do it in O(n3) bit operations Hence C is the correct answer... 7 7 replyShare Please log in or register to add a comment.
Best answer 17 17 votes $\begin{bmatrix} 0 & 1 & 1 & 0 & 0 & 1 \\ 1 & 0 & 1 & 1 & 0 & 0 \\ 0 & 1 & 0 & 1 & 1 & 1 \\ 1 & 1 & 1 & 0 & 1 & 0 \\ 0 & 1 & 0 & 1 & 0 & 1 \\ 1 & 1 & 0 & 1 & 1 & 0 \\ \end{bmatrix}$ If above is a binary relation in it's matrix representation. Then the following is the $O(V^3)$ Warshall's Algorithm to find the Transitive closure of the underlying graph or binary relation. for(int via = 0; via < V; via++) { for(int start = 0; start < V; start++) { for(int end = 0; end < V; end++) { matrix[start][end] = matrix[start][end] | ( matrix[start][via] & matrix[via][end] ); } } } dd answered May 7, 2017 • selected May 8, 2017 by ManojK dd comment Share Follow 0 reply Please log in or register to add a comment.
2 2 votes Option c is the answer anonymous answered May 7, 2017 anonymous comment Share Follow 0 reply Please log in or register to add a comment.
1 1 vote The time complexity of computing the transitive closure is: 3 nested for loops so time complexity is n^3. Option C Devwritt answered Feb 25, 2019 Devwritt comment Share Follow 0 reply Please log in or register to add a comment.