Question

2. Consider the following pseudocode for a disjoint-set implementation: Make-Set Cx) rank ) 0 Find-Set(x) return Find-Set (pLx) return LinkCx, y if rank]rank[y] else if rankx)rank y) rank[y]ran[y]1 Union (,y) Link (Find-Set (x), Find-Set(y)) Show the data structure that results and the answers returned by the Find-Set operations in the following program for i ? 1 to 16 Make-Set() for i ? 1 to 15 by 2 Union, ) for i1 to 13 by 4 UnionC, 2) UnionCi xs) Union(x11, x13) Union(x1, x10) Find-Set() Find-Set(g) 3. Repeat question 2, except that you use the following Find-Set routine instead. Find-Set(x) (p[r] ? Find-Set (p())) return return
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The main thing to understand is that in the first part the FindSet method is implemented without Path Compression, whereas in the second part, the FindSet method is implemented with Path Compression.

Make-Set (%) Union (di , χί») (Z3 3/(/S 3 2 /3 (x, Unisn (X11,13 Union tb 4 구 12/6 2 2 3 2.2) for ito16 Make-se (i Sanme data Shuctue as byevi ouus Some os breviou for Union(i Same as brevious nion( 8 16 6 12 1/Union (x,, x10 ) 6 12 구 /6 Find-Set (x) - l 6 나 2) 3 -ind. Set (x,)-16 l 6 /2 8 /o IS) (77 3 eviou 1 2. 3 4

Add a comment
Know the answer?
Add Answer to:
2. Consider the following pseudocode for a disjoint-set implementation: Make-Set Cx) rank ) 0 Find-Set(x) return...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT