Goal: show LPCC = O(m log n) over m operations 27:04.
access
accessdoes not change the represented tree at all — it only changes what is preferred. So light/heavy labels are untouched during an access27:04,27:46.- Walking up the tree, the newly preferred edges all lie on one root-to-
vpath, which contains at mostlog nlight edges28:24,29:26,29:56. - ⇒ ≤
log nlight preferred creations per access, ≤maccesses ⇒O(m log n)30:30.
link(v, w)
- Begins with
access(v)andaccess(w)— already paid for by the bullet above31:00. - Adding the edge changes light vs heavy: the path above
wgets heavier, other subtrees hanging off it get lighter34:00. - Neither costs anything against
LPCC34:41,35:15:- edges that got lighter are not preferred — irrelevant;
- edges that got heavier may cause heavy preferred creations — heavy creations are not counted at all.
- ⇒ The final edge insertion is free;
linkcosts only its two accesses35:40. - Student question — an edge that is still light after the link was already light before, so the access already paid for it
36:10. - Technical aside: with this implementation the linked edge isn't even on a preferred path, since after
access(w)the last access inv's subtree was tovitself, sovhas no preferred child36:32.
cut(v)
- Begins with
access(v)37:26. - Removing
v's subtree makes edges hanging off the preferred path heavier — not preferred, and heavy creations aren't counted anyway39:40. - But the edges along the preferred path itself get lighter, so there can be genuine light preferred creations there
40:22. - Bounded by
log n, because it is again a single root-to-leaf path40:22,41:03.
Result
mlink-cut tree operations takeO(m log² n + n log n)time.