Homework problem K on Binomial Heaps

Problem K

Assigned Oct 14+7, due Oct 28.

Binomial Heaps (based loosely on CLR 19.2-10).

  1. (5 points) Rewrite Binomial_Heap_Insert( H, k ) so that it's worst case run time, TIns(n), is Θ(1+lssb(n))[1], where lssb(n) is the number of consecutive least significant set bits in the binary representation of n, the number of keys in the heap at the time of insertion. Put another way, lssb(n) is the largest k such that 2k divides n + 1. For example, lssb(n) is 0 if n is even, and lssb(23=101112) is 3.

    You may start from the Binomial_Heap_Insert() in binomialHeap.h in the course directory. Your code is not required to be runnable C++ code, as long as it is sufficiently clear pseudocode. The testing code at the bottom of the file may be of help on part b.

  2. (5 points) Let S(n) = max{TIns(k): 1 ≤ k ≤ n)}. Show that S(n) is Θ(lg(n)).
Remark: To say S(n) is Θ(lg(n)) is a little stronger than saying that TIns(n) is both O(lg(n)) and Ω(lg(n)).

footnote:
[1]. corrected from Θ(lssb(n)), Oct 25.