0 1 2 3 4 Keys ( k i ) B D F H J Key probabilities ( p i ) - - PowerPoint PPT Presentation

0 1 2 3 4 keys k i b d f h j key probabilities p i 15 1
SMART_READER_LITE
LIVE PREVIEW

0 1 2 3 4 Keys ( k i ) B D F H J Key probabilities ( p i ) - - PowerPoint PPT Presentation

0 1 2 3 4 Keys ( k i ) B D F H J Key probabilities ( p i ) .15 .1 .05 .1 .2 Miss probabilities ( q i ) .05 .1 .05 .05 .05 .1 0 1 2 3 4 5 .1 D .1 .2 B .15 D J .1 .15 .1 B H H .1 .05 .1 .2 .05 .05 F J F


slide-1
SLIDE 1

1 2 3 4 Keys (ki) B D F H J Key probabilities (pi) .15 .1 .05 .1 .2 Miss probabilities (qi) .05 .1 .05 .05 .05 .1 1 2 3 4 5

slide-2
SLIDE 2

D

.1

B H F J

.15 .05 .05 .1 .2 .05 .1 .1 .05 .05

D

.1

B .15

.05 .1

J

.2

H F

.1 .05 .05 .05 .05 .1

For the left tree: .1+2(.15+.1)+3(.05+.1+.05+.2)+4(.05+.05+.05+.1) = 2.8 For the right tree: .1+2(.15+.2)+3+(.05+.1+.1+.1)+5(.05+.05)+5(.05+.05) = 2.75

slide-3
SLIDE 3

D B

Some subtree containing keys

F H J D B subtree best F H J D B subtree F H J non−best

slide-4
SLIDE 4

B

.05 .1 .15

total probability: .05 + .15 + .1 = .3 total weighted depth: 2 · .05 + .15 + 2 · .1 = .45

ki pi qi qi+1

total probability: qi + pi + qi+1 total weighted depth: 2 · qi + pi + 2 · qi+1

ki pi qi [ki+1, kj]

total probability: qi + pi + total prob [ki+1, kj] total weighted depth: 2 · qi + pi + ???

slide-5
SLIDE 5

j

x=i px · depth1(kx) + j+1 x=i qx · depth1(dx)

= 2 · qi + pi + j

x=i+1 px · depth1(kx) + j+1 x=i+1 qx · depth1(dx)

= 2 · qi + pi + j

x=i+1 px · (depth0(kx) + 1) + j+1 x=i+1 qx · (depth0(dx) + 1)

= 2 · qi + pi + j

x=i+1 px + j+1 x=i+1 qx + j x=i+1 px · depth0(kx) + j+1 x=i+1 qx · depth0(dx)

= qi + qi + pi + j

x=i+1 px + j+1 x=i+1 qx + (total weighted depth of subtree)

= qi + (total prob of tree) + (total weighted depth of subtree)

slide-6
SLIDE 6

ki pi qi [ki+1, kj]

total probability: qi + pi + T[i + 1][j] total weighted depth: qi + T[i][j] + C[i + 1][j]

[kr+1, kj] kr pr [ki, kr−1]

total probability: T[i][r − 1] + pr + T[r + 1][j] total weighted depth: C[i][r−1]+T[i][j]+C[r+ 1][j]

[ki, kj−1] kj pj qj+1

total probability: T[i][j − 1] + pj + qj+1 total weighted depth: C[i][j −1]+T[i][j]+qj+1

slide-7
SLIDE 7

values for [k0, kn−1], with interval n − 1 values for [k0, k0], with interval 0

n − 1

1 2 3

n − 2 n − 3 n − 4 n − 1

slide-8
SLIDE 8

For each diagonal from bottom up For each (i, j) in that diagonal Determine T[i][j], C[i][j], and the root of the best tree

slide-9
SLIDE 9

Initialize the cells (0, 0) through (n − 1, n − 1) For each interval size from 1 to n − 1 For each (i, j) in that interval (j = i + interval) Find T[i][j] Consider each key kr, keeping track of the root of the best tree seen so far and associated total weighted depth Special case for ki (r = i) Compute total weighted depth, assume it’s best so far For each kr ∈ [ki+1, . . . kj−1] (each r ∈ [i + 1, . . . j − 1) Compute total weighted depth, compare with best so far Special case for kj (r = j) Compute total weighted depth, compare with best so far Enter table entries for (i, j) Return tree rooted at cell (0, n − 1) in node tree