Question
Consider the elements 1..10 that will be used in a Disjoint Sets exercise. Using the Weighted Union and Collapsing Find heuristics, apply the following sequence
Consider the elements 1..10 that will be used in a Disjoint Sets exercise. Using the Weighted Union and Collapsing Find heuristics, apply the following sequence of operations, redrawing all the sets in tree representation after each operation. Remember that Find (i) returns a result but also might change the tree representation.
Note: For consistency, when calling Merge_trees (i,j) from within Union (i,j), if i and j are two trees of equal height, make Parent[i] = j (i.e. attach i under j).
- For i = 1 to 10do {makeset (i)}
- Union (6, 7) - Union (4, 10)
- Union (3, 1) - Union (2, 4)
- Union (1, 5) - Union (8, 2)
- Union (4, 6)
- Union (7, 1)
- Find (8)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started