Splay-Tree Static Finger and Working-Set Theorems #
This module proves two locality bounds of Sleator and Tarjan for sequences of accesses to keys
present in a splay tree, with explicit constants in the rotation-plus-one access-cost model
splaySeqCost (each access costs splayCost = max rotations 1 BST rotations,
[ST85b], Section 2, p. 658, rather than Word-RAM or Turing-machine instructions). Both
follow from the Access Lemma with inverse-square weights. The static finger weights 1/(d + 1)²
total at most 2 + 1 = 3: the keys at or below f have distinct distances d ≥ 0 and contribute
at most ∑_{k ≥ 1} 1/k² ≤ 2, and the keys above f have distinct distances d ≥ 1 and contribute
at most ∑_{k ≥ 2} 1/k² ≤ 1. The working-set weights 1/(t + 1)² total at most
∑_{k ≥ 1} 1/k² ≤ 2.
Main definitions #
fingerDist s f y: symmetric-order distance from the fingerftoyamong the keyss, the number of keys ofsin the half-open interval fromf(exclusive) toy(inclusive). Fors = {1, …, n}andf, y ∈ sit is|y - f|.recencyRank x l: the number of distinct keys before the first occurrence ofxinl.workingSetNumbers xs: the list oft(j)from [ST85b], Section 2, p. 659: the number of different keys accessed before accessjsince the last access of the same key, or since the beginning of the sequence for a first access.
Main results #
splaySeqCost_le_static_finger: Static Finger Theorem ([ST85b], Section 2, Theorem 3, p. 659): for a fixed keyf ∈ t,maccesses to present keys have rotation-plus-one access cost at most7m + 6 ∑ⱼ log₂(d(xⱼ) + 1) + n (2 + 2 log₂ n).splaySeqCost_le_working_set: Working Set Theorem ([ST85b], Section 2, Theorem 4, pp. 659–660):maccesses to present keys have rotation-plus-one access cost at most4m + 6 ∑ⱼ log₂(t(j) + 1) + n (1 + 2 log₂ n). The proof reassigns the weights1, 1/4, …, 1/n²in move-to-front order after each access and charges the reassignment throughpotential_reweight_root_le.
Both theorems assume every access is to a key stored in the tree, as in the source's analysis of item accesses; unsuccessful searches are not covered.
References #
- [ST85b] Daniel Dominic Sleator and Robert Endre Tarjan, Self-Adjusting Binary Search Trees, Journal of the ACM 32(3), Section 2, pp. 658–660, 1985.
Inverse-Square Sums and Binary-Logarithm Helper #
Static Finger Theorem #
Symmetric-order distance from the finger f to y among the keys s: the number of keys of
s in [y, f) when y ≤ f, and in (f, y] when f < y. For s = {1, …, n} and f, y ∈ s this
is |y - f|, the distance in [ST85b], Section 2, Theorem 3, p. 659.
The finger distance between keys of s is less than |s|: the counted keys exclude f.
Static Finger Theorem ([ST85b], Section 2, Theorem 3, p. 659): let t be an
Ordered splay tree with n = |t| keys and f ∈ t a fixed key. A sequence xs of m accesses to
keys of t has total rotation-plus-one access cost (splaySeqCost) at most
7m + 6 ∑ⱼ log₂(d(xⱼ) + 1) + n (2 + 2 log₂ n), where d = fingerDist (elements t) f is the
symmetric-order distance to f. The proof assigns static weights 1/(d(y) + 1)², with total
at most 3.
Working-Set Numbers and Move-to-Front Ranks #
The number of distinct keys before the first occurrence of x in l (all distinct keys of l
when x ∉ l). For a duplicate-free l this is the position of x in l; for a reversed access
history it is the position of x in the move-to-front list ([ST85b], Section 2,
p. 659).
Sleator–Tarjan working-set numbers ([ST85b], Section 2, p. 659): entry j is
t(j), the number of different keys accessed before access j since the last access of xs[j],
or since the beginning of the sequence if access j is the first access of xs[j]. The reversed
prefix lists earlier accesses from the most recent; recencyRank counts the distinct keys before
the most recent earlier access of xs[j].
Working Set Theorem #
Working Set Theorem ([ST85b], Section 2, Theorem 4, pp. 659–660): let t be
an Ordered splay tree with n = |t| keys. A sequence xs of m accesses to keys of t has
total rotation-plus-one access cost (splaySeqCost) at most
4m + 6 ∑ⱼ log₂(t(j) + 1) + n (1 + 2 log₂ n), where
t(j) = (workingSetNumbers xs)[j] is the number of different keys accessed before access j
since the last access of xs[j], or since the beginning if access j is the first access of
xs[j].
The proof follows Sleator and Tarjan: the weights 1, 1/4, …, 1/n² are assigned in move-to-front
order (initially in order of first access, never-accessed keys last), so the key accessed at step
j has weight 1/(t(j) + 1)² and the total weight is at most 2. After each access the weights
are reassigned with the accessed key, now at the root, moved to the front; this reassignment keeps
the root size and decreases every other size, so it does not increase the potential.