edited by
5,252 views
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)$

3 Answers

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] );
    }
  }
}
selected by
2 2 votes
Option c is the answer
1 1 vote
The time complexity of computing the transitive closure is:

3 nested for loops so time complexity is n^3.

Option C
Answer:
Position:
Show:

Related questions

8 8 votes
1 answers 1 answer
7.4k
7.4k views
sh!va asked May 7, 2017
7,391 views
Estimation at software development effort for organic software in basic COCOMO is:E = 2.0 (KLOC) 1.05 PME = 3.4 (KLOC) 1.06 PME = 2.4 (KLOC) 1.05 PME = 2.4 (KLOC) 1.07...
9 9 votes
5 answers 5 answers
8.9k
8.9k views
go_editor asked Sep 28, 2014
8,877 views
In the context of modular software design, which one of the following combinations is desirable?High cohesion and high couplingHigh cohesion and low couplingLow cohesion ...
10 10 votes
7 answers 7 answers
13.3k
13.3k views
sh!va asked May 7, 2017
13,302 views
The number of swappings needed to sort the numbers $8 , 22, 7, 9, 31, 5, 13$ in ascending order using bubble sort is$11$$12$$13$$10$
12 12 votes
6 answers 6 answers
8.4k
8.4k views
sh!va asked May 7, 2017
8,368 views
Which one of the following in-place sorting algorithms needs the minimum number of swaps?Insertion SortQuick SortHeap SortSelection Sort