day8 2/4/98 ``I'd do it, but it probably doesn't work.''

1.  Treaps, continued

1.1  timing analses for search

Then the expected number of ancestors of j is åi = 1n[1/( |j-i|+1)] £ 2åi = 1n1/i = 2*ln(n)

1.2  number of rotations in a delete.

The expected number of rotations in a delete is less than 2. The number of rotations is less than the sum of the rightmost branch (right spine) of the left child and the leftmost branch (left spine) of the right child.

analyse the right spine.

pi £ j{j = ancestor(i)Ùi Î rightspine} = random order of {i,...,j} with j first and i second = [1/( (j-i+1)(j-i))]

let size of right spine = Gj . Then E(Gj) = åi = 2j-1[1/( i(i-1))] = [(j-1)/( j)]

1.3  dynamic treaps

When a particular element is accessed adjust it's priority so the elements float towards the top of the treap.

old p(k) uniform in [0,1] .

new p(k) = min(p(k),random Î [0,1])

2.  Binomial and Fibonacci heaps

2.1  An algorithm using these structures

2.1.1 Dijkstra's algorithm

  1. W = V-{s} , D(s) = 0
  2. "u Î W do D(u) = l(s,u)
  3. while W ¹ 0
  4. u = Extractmin(W,D)
  5. "(u,v) Î E with v Î W , D(v) = min(D(v),D(u)+l(u,v))
  6. endwhile

2.1.2 timing analyses

with a good data structure you can get:

#
cost/op
totalcost
step2(insert)
n
O(1)
O(n)
step4(deletemin)
n
O(log(n))
O(n*log(n))
step5(decrement)
m
O(1)
O(m)

2.2  binomial heap operations

2.3  definition of binomial trees

Since the number of elements in each Bi doubles with i, you can have a heap of arbitrariy (integer) size represented as a set of Bi trees of different sizes.

2.4  operation implementations

2.4.1 meld(h,h')

Essentially, you just do binary addition between the sets of trees in h and h'. The amortized cost of adding an element to the heap is 2.


File translated from TEX by TTH, version 1.30.