Link-Cut Trees

Link-Cut trees maintain forests with O(log n) operations for linking, cutting, and path queries.

39 lessons
120 min

Lessons

1. Intro

Why Link-Cut trees matter

3m

2. Dynamic Tree Problems

Where static fails

2m

3. Operations We Need

The interface

2m

4. Splay Tree Review

The building block

3m

5. Rotations

Tree restructuring

3m

6. Preferred Paths

The core idea

3m

7. Auxiliary Trees

Splay trees for paths

4m

8. Path-Parent Pointer

Connecting auxiliary trees

3m

9. The Access Operation

Core of Link-Cut trees

5m

10. Access: Step by Step

Understanding the process

4m

11. FindRoot Operation

Find tree root

3m

12. Link Operation

Connect two trees

3m

13. Cut Operation

Remove an edge

3m

14. MakeRoot Operation

Rerooting a tree

4m

15. Why Rerooting Works

The reversal trick

3m

16. Path Query

Aggregate on path

4m

17. Path Update

Modify path values

3m

18. LCA Query

Lowest common ancestor

3m

19. Connected Query

Same tree check

2m

20. Node Structure

Complete fields

3m

21. Splay with Push Down

Handling lazy flags

4m

22. Rotate with Update

Maintaining aggregates

4m

23. Example: Building a Tree

Step by step links

3m

24. Example: Cut and Reconnect

Dynamic modification

3m

25. Application: Dynamic MST

Changing edge weights

3m

26. Application: Max Flow

Finding augmenting paths

3m

27. Application: Online LCA

Dynamic tree queries

2m

28. Problem - Dynamic Connectivity

Link, cut, connected

2m1 problems

29. Dynamic Connectivity Solution

Link-Cut tree approach

4m1 problems

30. Problem - Dynamic Path Queries

Sum on changing paths

2m

31. Dynamic Path Solution

With lazy propagation

3m

32. Amortized Analysis

Why O(log n)

3m

33. Space Complexity

Memory usage

2m

34. Implementation Tips

Practical advice

3m

35. Common Bugs

Debugging Link-Cut trees

3m

36. Euler Tour Trees

Alternative approach

3m

37. Top Trees

More powerful variant

2m

38. Quiz: Link-Cut Trees

Test your understanding

5m1 problems

39. Section Recap

What you learned

3m

Ready to start learning?

Access all 39 lessons with interactive content and progress tracking.