retagged by
32,244 views
51 51 votes

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

  1. $O(n)$

  2. $O(n \log  n)$

  3. $O \left( n^{\frac{3}{2}} \right)$

  4. $O\left(n^3\right)$

7 Answers

Best answer
60 60 votes

Answer $D$

Calculating Transitive Closure boils down to Matrix Multiplication.

We can do Matrix Multiplication in $O(n^{3})$. There are better algo that do less than cubic time, but we can not surely do matrix multiplication in

  • (A) $O(n)$
  • (B) $O(n \log n)$
  • (C) $O (n^{1.5})$
edited by
10 10 votes

Transitive closure is computed by Floyd -Warshals algorithm, and the time complexity for this is equal to O(n^3) .

The correct answer is (D) O(n^3)
7 7 votes
warshall algorithim can find transitive closure of any set in O(n3) time. (it basically finds the direct and indirect path from a node to other).
7 7 votes
Here is a more intuitive way you can understand. :)

1. For a set of n elements there are O(n^2) tuples in a relation.

2. To check the transitive completeness of one tuple E.g., (a,b) in the array, we first need to find if (a,b)'s transitive pair is present i.e (b,1), (b,2) ... (b, n) in this array (which is O(n) in worst case).

3. After we find the corresponding pairs, we check if the transitive closure of each pair that was found is present. (This is only take O(1) as it is a simple check and add condition). Therefore the time taken to complete the transitive closure of one tuple is O(n).

4. To do this for all elements in the array it is O(n^2) * O(n) which is O(n^3)
Answer:
Position:
Show:

Related questions

33 33 votes
7 answers 7 answers
14.5k
14.5k views
gatecse asked Sep 21, 2014
14,496 views
Let $R$ and $S$ be any two equivalence relations on a non-empty set $A$. Which one of the following statements is TRUE?$R$ $∪$ $S$, $R$ $∩$ $S$ are both equivalence relat...
197 197 votes
8 answers 8 answers
76.5k
76.5k views
Kathleen asked Sep 22, 2014
76,478 views
A $5$ stage pipelined CPU has the following sequence of stages:IF – instruction fetch from instruction memoryRD – Instruction decode and register readEX – Execute: ALU op...
32 32 votes
3 answers 3 answers
15.2k
15.2k views
gatecse asked Sep 21, 2014
15,211 views
Let $f(x)$ be the continuous probability density function of a random variable $x$, the probability that $a < x \leq b$, is :$f(b-a)$$f(b) - f(a)$$\int\limits_a^b f(x) dx...
41 41 votes
6 answers 6 answers
12.8k
12.8k views
gatecse asked Sep 21, 2014
12,814 views
Consider the set $H$ of all $3 * 3$ matrices of the type $$\left( \begin{array}{ccc} a & f & e \\ 0 & b & d \\ 0 & 0 & c \end{array} \right)$$ where $a,b,c,d,e$ and $f$ a...