Question: Can you solve both a ) and b ) with mathematical proofs. Heap - Build Methods. ( a ) In the top - down heap

Can you solve both a) and b) with mathematical proofs.
Heap-Build Methods.
(a) In the top-down heap-build method, we use MAX-HEAP-INSERT repeatedly, starting
with an empty heap and inserting from position 1 to n , resolving the heap structure
by "bubbling up" each new insertion. This means the 2i nodes on level i will each
cause up to i swaps, resulting in the following expression:
total ??# swaps =(??# nodes )(??#swaps)
1*0+2*1+22*2+dots+2i*i+dots+n2*(logn-1)
Prove that the expression on the right side of the inequality is (nlogn).
Hint: Lower bound is easy. For the upper bound, exaggerate the amount of bubbling
up to be logn per node.
(b) In the bottom-up heap-build method, we use Max-Heapify repeatedly from po-
sition n to 1, resolving the heap structure by "bubbling down" from each position
in turn; however, the first n2 positions are leaves and thus already heaps, so they
cause 0 swaps. The n4 nodes directly above (at height 1) will each cause up to 1
swap, and so on, resulting in the following expression:
total ??# swaps n2*0+n4*1+n8*2+dots+n2k*(k-1)+dots+1*(logn-1)
We can factor out n, rewriting as:
total ??# swaps n(12*0+14*1+18*2+dots+12k*(k-1)+dots+1n*(logn-1))
Prove that the above parenthetical expression is bounded above by a
constant, thus the expression is (n).
Hint: One method is the following. First, bound above by the corresponding infinite
series. Try to subtract from the parenthetical expression the sum 122+123+124+dots
and factor out 12. Compare the result with the initial expression and figure out what
to do next.
Can you solve both a ) and b ) with mathematical

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!