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.
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(n^2)"
Comments
Leave a comment