The key accounting identity
- The number of splays performed during an
accessisO(1 + PCC), wherePCC= preferred child changes in that call6:39,7:22. - Reason: each preferred child change forces one splay of
vupward, merging with the new preferred parent, repeating untilvreaches the root aux tree7:22.
Summing over m operations
- Total runtime ≤ (worst-case cost of a splay) × (
m+ total PCC across allmoperations)8:06. - The
+mterm is the1in1 + PCC, summed over themoperations — a student asks about it explicitly8:43,9:34. - Worst-case splay cost is
O(log n)8:43.
Why this is deliberately sloppy
- Charging worst-case splay cost × number of PCCs is wasteful. The pset problem shows the amortized cost of all splays combined is already on that order, which is where the improvement from
log² ntolog ncomes from9:34,9:56.
What remains to prove
- The whole remaining task: show
PCC = O(m log n). Combined with theO(log n)splay cost, that yieldsO(m log² n)9:56.