Implementing Disjoint Set using Linked List.
Implementation
- Each set is a linked list
make-set()make a linked listx.setis a pointer to x’s owning listfind-set(x)will follow the pointerunion(S1,S2)merges linked lists, always move smaller list into the larger one.
Amortized Analysis
Union
- Each
x.setis updated at most times - There are set fields
- Total number of updates is at most
- Amortized time for operations
make-set(),find-set(),union()overall