Question
5. Consider the following two methods for implementing the buildHeap function for a binomial heap. (a) The first method is to represent all the input
5. Consider the following two methods for implementing the buildHeap function for a binomial heap.
(a) The first method is to represent all the input values as B0 trees and to merge them one at a time into an initially empty heap. We can estimate the run time of this approach by considering the number of bits that change when repeatedly adding one to binary to a number that is initially zero. Develop an expression for the run time of this version of buildHeap in terms of N, where N = 2p
(b) The second method is to represent all the input values as B0 trees, place them on a queue, then repeatedly take two trees from the head of the queue, merge them, and put the resulting tree on the back of the queue. This process is repeated until the queue contains only one tree. Develop an expression for the run time of this version of buildHeap in terms of N, where N = 2p .
(c) Considering all factors, which method is best? Explain.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started