retagged by
24,668 views
36 votes
36 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)$

retagged by

6 Answers

4 votes
4 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:

Related questions

24 votes
24 votes
3 answers
4
gatecse asked Sep 21, 2014
7,140 views
The set \(\{1, 2, 4, 7, 8, 11, 13, 14\}\) is a group under multiplication modulo $15$. The inverses of $4$ and $7$ are respectively:$3$ and $13$$2$ and $11$$4$ and $13$$8...