Question #191417

Suppose you are given n sets:S1,S2.....Sn each set is having n elements.the problems is to find whether some pairs of these sets are disjoint,i.e. there are no common elements in these sets.write pseudo code and calculate its time complexity.


Expert's answer

Start
Scan elements A[n], B[n]
for loop initiated i to n
  for loop initiated j to n
      if(A[i]==B[j])
        Set is not not a disjoint
      else 
        set is disjoint
stop

Time complexity of the code T(n)=O(n2)T(n)=O(n^2)

LATEST TUTORIALS
APPROVED BY CLIENTS