Question

What is the running time to remove the maximum value and restore heap properties?

What is the running time to remove the maximum value and restore heap properties?

Homework Answers

Answer #1

Ans : O(log n)

Explanation:

to remove max element from Heap takes O(1) time and To restore the heap It takes O(log n).

While restoring the heap we place last element of heap at the top and Go down the tree height while satisfying the condition of heap (parent node should be grater than its children node) .So we travel height of the heap while restoring the heap.

Total Running Time = O ((log n ) +1) =O(log n)     where n is number of elements in heap.  

NOTE: If you got any sort of help from this article please UPVOTE and in case of query do mention it in comments

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
What is the worst-case time (in Big-O) for building a Min-Heap of N nodes, using bulk...
What is the worst-case time (in Big-O) for building a Min-Heap of N nodes, using bulk insertion (bottom-up construction), assuming comparing two keys takes constant time. Justify your answer. You may assume N = 2h+1 – 1, for simplicity.
An array contains 10 elements. What is the maximum number of swaps required to convert the...
An array contains 10 elements. What is the maximum number of swaps required to convert the array to a max heap?
In order to answer the following questions you need by maximum 500 words 1. What properties...
In order to answer the following questions you need by maximum 500 words 1. What properties of ATP make it especially effective in driving forward biochemical reactions.
Provide an algorithm that solves the following problem: input: a binary heap B, an integer value...
Provide an algorithm that solves the following problem: input: a binary heap B, an integer value x output: all keys in B that are smaller than x Constraint: your algorithm must run in time O(K), where K is the number of keys output. Explain why your algorithm has the required runtime behaviour. (Use pseudocode or C++, or any informal (but clear) description. You are free to choose any kind of representation of binary heaps, as long as it was mentioned...
A brand new SGI Altix Intel Itanium system has 64 CPUs running Linux OS. What is...
A brand new SGI Altix Intel Itanium system has 64 CPUs running Linux OS. What is the maximum number of processes in RUNNING state at a single time when it executes 200 processes? What is the maximum number of processes in BLOCKED state?
A brand new SGI Altix Intel Itanium system has 64 CPUs running Linux OS. What is...
A brand new SGI Altix Intel Itanium system has 64 CPUs running Linux OS. What is the maximum number of processes in RUNNING state at a single time when it executes 200 processes? What is the maximum number of processes in BLOCKED state?
Find the maximum running speed of an animal that weighs 11 g and grows at a...
Find the maximum running speed of an animal that weighs 11 g and grows at a rate of .02 grams per day if speed is determined by: s=1.1w^0.2 to estimate the maximum sprinting speed s (meters per second) of a lizard of mass w (grams). At what rate is the maximum sprinting speed of an 11 gram lizard increasing if the lizard is growing at the rate of 0.02 grams per day?
‏What is the output of the Euler tour in the normal binary search tree if the...
‏What is the output of the Euler tour in the normal binary search tree if the key insert order is 5 , 2 , 8 , 5 , 9 , 5 , 1 , 3 , 4 , 2 , 8 ? All keys equal to the node should be the right subtree of that node. ____________________________________________________________ ‏Construct the binary max - heap for the keys given below. Once all the keys are inserted, perform the remove maximum operation, and...
Nancy believes that the average running time of movies is equal to 170 minutes. A sample...
Nancy believes that the average running time of movies is equal to 170 minutes. A sample of 7 movies was taken and the following running times were obtained. Assume the population of the running times is normally distributed as 158 162, 170 182,185,189,195 Using the p-value approach as well as critical value approach, test the hypotheses at the 10% level of significance.
Nancy believes that the average running time of movies is equal to 170 minutes. A sample...
Nancy believes that the average running time of movies is equal to 170 minutes. A sample of 7 movies was taken and the following running times were obtained. Assume the population of the running times is normally distributed as 158 162, 170 182,185,189,195 Using the p-value approach as well as critical value approach, test the hypotheses at the 10% level of significance.