Link-Cut Trees
Link-Cut trees maintain forests with O(log n) operations for linking, cutting, and path queries.
Lessons
1. Intro
Why Link-Cut trees matter
2. Dynamic Tree Problems
Where static fails
3. Operations We Need
The interface
4. Splay Tree Review
The building block
5. Rotations
Tree restructuring
6. Preferred Paths
The core idea
7. Auxiliary Trees
Splay trees for paths
8. Path-Parent Pointer
Connecting auxiliary trees
9. The Access Operation
Core of Link-Cut trees
10. Access: Step by Step
Understanding the process
11. FindRoot Operation
Find tree root
12. Link Operation
Connect two trees
13. Cut Operation
Remove an edge
14. MakeRoot Operation
Rerooting a tree
15. Why Rerooting Works
The reversal trick
16. Path Query
Aggregate on path
17. Path Update
Modify path values
18. LCA Query
Lowest common ancestor
19. Connected Query
Same tree check
20. Node Structure
Complete fields
21. Splay with Push Down
Handling lazy flags
22. Rotate with Update
Maintaining aggregates
23. Example: Building a Tree
Step by step links
24. Example: Cut and Reconnect
Dynamic modification
25. Application: Dynamic MST
Changing edge weights
26. Application: Max Flow
Finding augmenting paths
27. Application: Online LCA
Dynamic tree queries
28. Problem - Dynamic Connectivity
Link, cut, connected
29. Dynamic Connectivity Solution
Link-Cut tree approach
30. Problem - Dynamic Path Queries
Sum on changing paths
31. Dynamic Path Solution
With lazy propagation
32. Amortized Analysis
Why O(log n)
33. Space Complexity
Memory usage
34. Implementation Tips
Practical advice
35. Common Bugs
Debugging Link-Cut trees
36. Euler Tour Trees
Alternative approach
37. Top Trees
More powerful variant
38. Quiz: Link-Cut Trees
Test your understanding
39. Section Recap
What you learned