1 / 8

Potential Function (part 1/2)

1. 7. 2. 5. 2. 1. 3. 1. 3. 3. 1. 4. 4. 1. L(T) = 19. W(T) = 19. Potential Function (part 1/2). 1+depth T (x) = # ancestors of x (including x) in T = access cost of x in T.

ellie
Download Presentation

Potential Function (part 1/2)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 1 7 2 5 2 1 3 1 3 3 1 4 4 1 L(T) = 19 W(T) = 19 Potential Function (part 1/2) • 1+depthT(x) = # ancestors of x (including x) in T = access cost of x in T. • wT(x) = weight of x in T = # descendents of x (including x) in T = # nodes in the subtree rooted at x. • Candidate 1:Internal path length of T: L(T) = SxT (1+depthT(x)). • Candidate 2:Weight of T: W(T) = SxT wT(x). • FACT: (1) T L(T) = W(T). Why? • (2) As potentials, L(T) and W(T) are regular (i.e., always  0, L() = W() = 0). • (3) Q(n log n)  L(T) = W(T) Q(n2), where n=|T|. • L(T) & W(T) can become too large. They won’t work!Dampen W(T) by a sublinear function, e.g., log.

  2. F(n) = F(n-1) + log n = Q(n log n) F(n) = 2 F(n/2) + log n = Q(n) Potential Function (part 2/2) • Rank of x in T: rT(x) = log wT(x). • Potential:F(T) = SxTrT(x). • FACT:F(T) is also regular, and Q(n) F(T) Q(n log n).

  3. log b log (a+b)/2 (log a + log b)/2 log a a (a+b)/2 b This makes the potential function work! The LOG LEMMA LEMMA 0: For any numbers a, b, c  1 a + b  c  log a + log b  2 log c – 2. Proof 1: c2 (a+b)2 = 4ab + (a-b)2  4ab. So, c2  4ab. Now take log. Proof 2: Logarithm is a concave function:

  4. root x LEMMA 1: root y ZIG y x A C T B C ĉ 1 + 3[rT’ (x) – rT (x)] A B T’ ZIG LEMMA Proof:

  5. z LEMMA 2: x ZIG-ZIG y y z x D A C ĉ 3[rT’ (x) – rT (x)] B A B C D T T’ ZIG-ZIG LEMMA Proof:

  6. z LEMMA 3: ZIG-ZAG T’ y x D T ĉ 3[rT’ (x) – rT (x)] A B C x y z A B C D ZIG-ZAG LEMMA Proof:

  7. z x root x LEMMA 1: root y y ZIG y y x z x D A A T C T B B C A ĉ 1 + 3[rT’ (x) – rT (x)] A B T’ C D B C T’ z LEMMA 2: ZIG-ZIG y x D T C ĉ 3[rT’ (x) – rT (x)] A B LEMMA 3: ZIG-ZAG x T’ y z ĉ 3[rT’ (x) – rT (x)] A B C D Lemmas on each Splay Step

  8. Proof: Splay(x) operation is a sequence of splay steps: ci Tbefore = T0  Ti-1 Ti  Tk = Tafter ĉi Fbefore = F0 Fi-1 Fi Fk= Fafter Amortized cost of Splay THEOREM 1: Amortized number of rotations by a Splay operation on an n-node BST is at most 3 log n + 1. only last splay step can be a ZIG

More Related