Question: Implement a disjoint set system using a tree representation (use references, or a parent array). In particular, you should implement an Initialize() function that creates

Implement a disjoint set system using a tree representation (use references, or a parent array). In particular, you should implement an Initialize() function that creates n one-element sets given an array of n things, as well as the functions Find() and Merge(). Implement the better version of disjoint sets (where smaller sets parent to larger sets and finds implement path compression).

 Importing set.py should provide the following functions: set.Initialize(Values) -- return a new set system with one element per set. Values is a list of values for the sets set.Find(set, value) -- Return the name of the set in which value lives. Do path compression. Exactly what you return isn't important, as long as Find(set, val1) and Find(set, val2) are equal if and only if val1 and val2 are in the same set. set.Merge(set, value1, value2) -- Merge operation. Make sure you parent 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!