Data Structures19 sections · 729 units
Open in Course

Amortized Analysis

Why O(log n)

Link-Cut tree operations are O(logn)O(\log n) amortized, not worst-case. Potential function argument: Define potential based on "heavy" vs "light" edges in the preferred path decomposition.

Each access changes O(logn)O(\log n) light-to-heavy edge classifications amortized. Intuition:

  • Splaying moves accessed nodes to root, making future accesses faster
  • Access changes preferred paths, but each change is "paid for" by the operation causing it
  • Over mm operations, total work is O(mlogn)O(m \log n)

Single operations can be O(n)O(n) in worst case, but sequences of mm operations take O(mlogn)O(m \log n) total.