Please enable JavaScript.
Coggle requires JavaScript to display documents.
Algorithms (Searching (Union Find (Implementations (Quick-union (lazy…
Algorithms
Searching
-
Implementations
Quick-find
Find - objects p and q are connected if they have the same id
Union - change ids of all objects in p's set to that of q's set
problems:
- too many values need to change id, which can be slow
- lost info of previous set ids
-
Quick-union
-
-
-
problems:
- trees can get too tall
- need to do find to do union
Improvements
-
Path Compression
after finding root for a node, set id of each examined node in the path to the root, to flatten the tree
solution: make every other node in the path point to its grandparent, just one line: id[i] = id[id[i]]
-
-