← 🌲 Algorithms

🌲 Link-Cut Tree

Path Length:
Splay Operations:
Drag — rotate · Scroll — zoom

🌲 Link-Cut Tree

The simulator demonstrates how a link-cut tree decomposes a dynamic forest into preferred paths represented as splay trees, and how access, link, and cut operations splice these paths together to keep path queries fast even as the forest's shape changes.

🔬 What It Demonstrates

The simulator demonstrates how a link-cut tree decomposes a dynamic forest into preferred paths represented as splay trees, and how access, link, and cut operations splice these paths together to keep path queries fast even as the forest's shape changes.

🎮 How to Use

Add nodes to build a forest, then use link to attach one tree under another and cut to detach a subtree. Trigger an access on any node to see the preferred path from that node to its root highlighted, and watch the underlying splay-tree reorganization happen step by step. Run a path query, such as minimum edge weight, between two nodes to see the access operation used to answer it.

💡 Did You Know?

A single access operation in a link-cut tree can restructure the entire preferred-path decomposition along the way to the root, yet the amortized cost still works out to logarithmic time, the same trick that makes ordinary splay trees efficient despite occasionally expensive individual operations.