Consider the program
for i from 1 to 60:
MakeSet(i)
for i from 1 to 30:
Union(i, 2*i)
for i from 1 to 20:
Union(i, 3*i)
for i from 1 to 12:
Union(i, 5*i)
for i from 1 to 60:
Find(i)
I would like to determine the height of the disjoint set.
What I understand?
MakeSet(i) creates a new set whose only member is pointed by i
, and
Unique(i,j) unites two dynamic sets containing objects i
and j
, into a new set Si ∪ Sj
So, the first for
loop will populate a set with 60 elements, then the second for
loop combines the elements making the set's lenth half of 60 which is 30. but next we are using 3*i, and i ranges till 20 so doesn't it go out of range. Or did I understand it wrong?
What will be the height of the disjoint set?
Thanks in advance.