Do Exercise 21.2-2 using a disjoint-set forest with union by rank and path compression.
1
/ | \ \
2 3 5 9
| / \ / / \
4 6 7 10 11 13
| | / \
8 12 14 15
|
16
Write a nonrecursive version of FIND-SET with path compression.
Give a sequence of m MAKE-SET, UNION, and FIND-SET operations, n of which are MAKE-SET operations, that takes Ω(m lg n) time when we use union by rank only.
Show that any sequence of m MAKE-SET, FIND-SET, and LINK operations, where all the LINK operations appear before any of the FIND-SET operations, takes only O(m) time if both path compression and union by rank are used. What happens in the same situation if only the path-compression heuristic is used?
UNSOLVED
Follow @louis1992 on github to help finish this task.