retagged by
2,147 views
3 votes
3 votes

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

  1. $O(n)$
  2. $O(n*\log(n))$
  3. $O(n^{\frac{3}{2}})$
  4. $O(n^{3})$
retagged by

4 Answers

Best answer
3 votes
3 votes

The matrix of the transitive closure of a relation on a set of n elements

can be found using $n2(2n-1)(n-1) + (n-1)n2$ bit operations, which gives the time complexity of $O(n4)$.

But using  Warshall's Algorithm: Transitive Closure we can do it in $O(n3)$ bit operations.

Hence $D$ is the correct answer.

edited by
0 votes
0 votes

ANSWER: D    O( n)

Transitive closure of a graph

Given a directed graph, find out if a vertex j is reachable from another vertex I for all vertex pairs (i, j) in the given graph. Here reachable means that there is a path from vertex I to j. The reach-ability matrix is called transitive closure of a graph.

transitiveclosure            

Transitive closure of above graphs is 
     1 1 1 1 
     1 1 1 1 
     1 1 1 1 
     0 0 0 1 

Floyd Warshall Algorithm can be used, we can calculate the distance matrix dist[V][V] using Floyd Warshall, if dist[i][j] is infinite, then j is not reachable from i, otherwise j is reachable and value of dist[i][j] will be less than V.

Time Complexity: O(V3) where V is the number of vertices in the given graph.

source: geeksforgeeks

Answer:

Related questions

8 votes
8 votes
3 answers
1
Arjun asked Apr 22, 2018
4,364 views
$(\text{G}, \ast )$ is an abelian group. Then$x= x^{-1}$ for any $x$ belonging to $\text{G}$$x=x^{2}$ for any $x$ belonging to $\text{G}$$\left( x \ast y \right )^{2}= x^...
5 votes
5 votes
2 answers
3
Arjun asked Apr 22, 2018
4,627 views
Consider the following C code segmentint f(int x) { if(x<1) return 1; else return (if(x-1)+g(x)); } int g(int x) { if(x<2) return 2; else return (if(x-1)+g(x/2)); }Of the...
5 votes
5 votes
2 answers
4
Arjun asked Apr 22, 2018
8,566 views
Consider the following program{ int x=1; printf("%d",(*char(char*)&x)); }Assuming required header files are included and if the machine in which this program is executed ...