|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Note:
|
|
Example:
r(T) = lg(15) + lg(11) + 2lg(5) + 3lg(3)
Notes:
Before splay(3): r(T) = lg(15) + lg(11) + 2lg(5) + 3lg(3) After splay(3): r'(T) = lg(15) + lg(11) + lg(9) + lg(5) + 3lg(3) Change in balance: Δ(r(T)) = r'(T) - r(T) = lg(9) - lg(5) |
|
|
|
(This is trivial because we added in the difference so the total will never become negative...)
|
To answer this question, we must look at the amortized cost of a zig-zig, a zig-zag, a zig operation
Because: splay(x) = a sequence of these operations
|
|
The proof for the zig-zag and zig step are similar to the zig-zig step (see Goodrich for details)
|
δ = r( new tree ) - r( old tree ) = r'(a) + r'(b) + .... + r'(x) + r'(y) + r'(z) - r(a) + r(b) + .... + r(x) + r(y) + r(z) = (r'(x) + r'(y) + r'(z)) - (r(x) + r(y) + r(z)) |
Because r(v) = lg(n(v)), we have that:
Therefore:
δ = (r'(x) + r'(y) + r'(z)) - (r(x) + r(y) + r(z)) ^^^^ ^^^^ = (r'(y) + r'(z)) - (r(x) + r(y)) ^^^^ < (r'(x) + r'(z)) - (r(x) + r(y)) = (r'(x) + r'(z)) - r(x) - r(y) ^^^^ < (r'(x) + r'(z)) - r(x) - r(x) < (r'(x) + r'(z)) - 2r(x) ........(2) |
|
|
Proof:
|
The amortized cost to splay a node x at depth d:
|
|
From Porposition 10.4: r'(T) - r(T) ≤ 3r(root) - 3r(x) - d + 2 <==> r'(T) - r(T) + d ≤ 3r(root) - 3r(x) + 2 <==> d + Δ(T) ≤ 3r(root) - 3r(x) + 2 ==> d + Δ(T) ≤ 3r(root) + 2 = 3*log(n(root)) + 2 = 3*log(2n+1) + 2 ==> d + Δ(T) = O(log(n)) |
|
But the change is very small (1 node compared to n nodes).
|
I'll omit it; the most difficult part of the proof have been discussed...