Question: For set - union - find data structure, we saw that total number of head pointer changes during all the union operations is O (
For setunionfind data structure, we saw that total number of head pointer changes during all the union operations is On log n Here, we try to improve upon this bound.
We are going to maintain two level disjoint set data structure. At the lower level this is a disjoint set data structure on V At the upper level, this is a disjoint set data structure on V V The change is that while doing unon at the lower level, if both the lists are log n then the union operation is performed at the upper level. At any point, after the union, if a list at lower level grows log n then the head element of that list is inserted into the upper level structure and a part of V
At the lower level structure, head element of each linked list maintains size of the list and also a field called upptr This points to the copy of head element of this list in upper level structure if one exists
For unionx y we do as follows: Let s findx and t findy If s and t both have non null upptr, then let s upptrs and t upptrt and then perform unionst in the upper level structure. Otherwise, assume wlog that sizes sizet Perform unions t If sizes becomes logn and upptrs is null, then insert a new singleton set s in upper level structure. Set s upptrs Both s and s hold the same vertex.
To determine whether findx is the same as findy or not, we first check if headx is same as heady If yes, then the answer is yes. If not, then we check if headupptrheadx is the same as headupptrheady If so the answer is yes, else the answer is no
a Show that V n log n
b Show that any element changes its head pointer no more than log log n times at the lower level.
c Show that any element in V will change its head pointer at most log n times.
d Show that total number of head pointer changes across all unions in upper and lower levels is On log log n
This improves Om n log n bound that we saw in the class to Om n log log n Any ideas if further improvement can be made?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
