Question: a. Prove that for binary heaps, buildHeap does at most 2N2 comparisons between elements. b. Show that a heap of eight elements can be constructed
a. Prove that for binary heaps, buildHeap does at most 2N−2 comparisons between elements.
b. Show that a heap of eight elements can be constructed in eight comparisons between heap elements.
c. Give an algorithm to build a binary heap in 13/8 N + O(logN) element comparisons.
Step by Step Solution
3.48 Rating (178 Votes )
There are 3 Steps involved in it
a We show that H N which is the sum of the heights of nodes in a complete binary tree of N nodes is N b N where b N is the number of ones in the binar... View full answer
Get step-by-step solutions from verified subject matter experts
Document Format (1 attachment)
1486-C-S-A(406).docx
120 KBs Word File
