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.
HeapBuild Methods.
a In the topdown heapbuild method, we use MAXHEAPINSERT repeatedly, starting
with an empty heap and inserting from position to n resolving the heap structure
by "bubbling up each new insertion. This means the nodes on level i will each
cause up to i swaps, resulting in the following expression:
total # swaps # nodes #swaps
dotsdots
Prove that the expression on the right side of the inequality is
Hint: Lower bound is easy. For the upper bound, exaggerate the amount of bubbling
up to be per node.
b In the bottomup heapbuild method, we use MaxHeapify repeatedly from po
sition to resolving the heap structure by "bubbling down" from each position
in turn; however, the first positions are leaves and thus already heaps, so they
cause swaps. The nodes directly above at height will each cause up to
swap, and so on resulting in the following expression:
total # swaps dotsdots
We can factor out rewriting as:
total # swaps dotsdots
Prove that the above parenthetical expression is bounded above by a
constant, thus the expression is
Hint: One method is the following. First, bound above by the corresponding infinite
series. Try to subtract from the parenthetical expression the sum dots
and factor out Compare the result with the initial expression and figure out what
to do next.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
