Work Note 2, DM803, fall 2014

Lecture September 9

Exercises September 10

  1. Show that there is at most a logarithmic number of nodes on the right-most path in a leftist heap with n element.
    Hint: Show that a node of rank r has exponentially many nodes in its subtree. Then consider how ranks behave on the right-most path.

  2. Show that two standard heaps (as known from DM507) with 2p-1 elements each plus one extra element x can be combined into one heap in time O(p).
    Show that a standard heap can be build out of n=2p-1 elements in time O(n) by a bottom-up application of the result above.
    Given n elements, how can a leftist heap be constructed in time O(n)?

  3. How can the operations decreasekey, delete, and update be implemented to run in time O(log n) for leftist heaps? It is assumed that you are given a reference to the element and you may introduce additional references in the structure.
    Hint: Some operations can be reduced to others.

  4. [CLRS09] 17.3-3, 17.3-6, 17.3-7.
    Hint: in 17.3-7, you may assume that the median of n elements can be found in time O(n).

  5. Come up with an implementation of a queue (not priority queue), where, in addition to the usual operations enqueue and dequeue, there is an operation findmin that reports the minimum element in the queue (assuming we have a total ordering on the elements). All operations should be OA(1).

  6. Computational considerations are always with respect to a model of computation. You may have heard of the comparison model, the RAM model, the word RAM model, etc. In data structures, the classic model is the pointer model. Here it is assumed that you cannot use random access, i.e., you can, for instance, not index into an array, so operations such as A[i] are not allowed. Can we prove all the operations of Fibonacci Heaps to be as efficient as usual with that restriction?

  7. Here is an alternative to leftist heaps: As for leftist heaps, we consider binary heap-ordered trees. However, instead of rank, each node has a size attribute, storing the size of the subtree in which it is a root. Just as for leftist heaps, we define meld, and then all other operations follow from that.
    The meld operation is defined as follows. Assume that we meld X and Y, and assume that X has the smallest key k in the root (otherwise we just switch the two arguments) and that its two subtrees are Xleft and Xright
    Now sort the trees Xleft, Xright, and Y in non-decreasing order of size and name them A, B, and C, i.e., A.size ≤ B.size ≤ C.size. Make a node that has k in the root and the two subtrees meld(A,B) and C.
    Consider correctness and complexity.

  8. For skew heaps, what if we define heavy as |Tr(x)| ≥ ¾ |Tx|? Or |Tr(x)| ≥ ¼ |Tx|? How does that affect the analysis?


Last modified: Thu Sep 4 08:35:39 CEST 2014
Kim Skak Larsen (kslarsen@imada.sdu.dk)