how heaps can be implemented using an array. In this problem we consider using an implementation...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
how heaps can be implemented using an array. In this problem we consider using an implementation using pointers. (a) Consider storing a heap as a linked binary tree with pointers. Give pseudo- code on how you would store a heap node, and which modifications you need to make to the heap routines that we discussed in class. What are the runtimes of the heap routines? (b) Now consider storing a heap as a linked list with pointers. Give pseudo-code on how you would store a heap node, and which modifications you need to make to the heap routines that we discussed in class. What are the runtimes of the heap routines? (c) Which of the three heap implementations (array, linked tree, linked list) is preferrable? Justify your answer. (d) Assume you are given two heaps of height h each, that are given as linked binary trees. And assume we do not require that the last level of the heap is "flushed left", i.e., keys can be in any place in the last level. Give an efficient algorithm that merges those two heaps into one heap (without the "flushed left" condition). Analyze the runtime of your algorithm. how heaps can be implemented using an array. In this problem we consider using an implementation using pointers. (a) Consider storing a heap as a linked binary tree with pointers. Give pseudo- code on how you would store a heap node, and which modifications you need to make to the heap routines that we discussed in class. What are the runtimes of the heap routines? (b) Now consider storing a heap as a linked list with pointers. Give pseudo-code on how you would store a heap node, and which modifications you need to make to the heap routines that we discussed in class. What are the runtimes of the heap routines? (c) Which of the three heap implementations (array, linked tree, linked list) is preferrable? Justify your answer. (d) Assume you are given two heaps of height h each, that are given as linked binary trees. And assume we do not require that the last level of the heap is "flushed left", i.e., keys can be in any place in the last level. Give an efficient algorithm that merges those two heaps into one heap (without the "flushed left" condition). Analyze the runtime of your algorithm.
Expert Answer:
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these algorithms questions
-
In this question you will be asked to reflect on a project you have been involved in or observed, in which a design evolved, or could have evolved, through applying a theory of user behaviour. You...
-
In a Hopfield neural network configured as an associative memory, with all of its weights trained and fixed, what three possible behaviours may occur over time in configuration space as the net...
-
Q1-Mutual funds provide the following for their shareholders. A. diversification B. professional management C. record keeping and administration D. all of these options
-
In your opinion, do you think an MNE should remain politically neutral and adopt practices and laws of the host country?
-
The time required by a mechanic to repair a machine has an exponential distribution with a mean of 4 hours. However, a special tool would reduce this mean to 2 hours. If the mechanic repairs a...
-
James Cameron piloted a submersible craft to the bottom of the Challenger Deep, the deepest point on the oceans floor, 11,000 m below the surface. What was the total inward force on the...
-
Westover Corporation had $300,000, 10-year bonds outstanding on December 31, 2011 (end of the accounting period). Interest is payable each December 31. The bonds were issued on January 1, 2011. The...
-
Who has completed the failure containment training. What Failure Modes to monitor and check for. Processes to follow when an out-of-control condition occurs. Reasons why specific defect prevention...
-
Cassi Taxpayer (SSN 412-34-5670) who is single, has a home cleaning business she runs as a sole proprietorship. The following are the results from business operations for the tax year 2014: Gross...
-
If you have a 10ml cylinder with a volume of 2.6ml. To determine the density of a gold ring, it is dropped on the test tube and it was observed that the water level increased s (what is observed in...
-
write a program that receives the ASCII code value of the integer type and the alphabet character from the user, and prints the ASCII code character of the corresponding integer and the ASCII code...
-
Allied Biscuit Co. is expected to generate a free cash flow (FCF) of $11,600.00 million this year (FCF? = $11,600.00 million), and the FCF is expected to grow at a rate of 22.60% over the following...
-
what would be the firm's ratio of net ppe/fross ppe under the fc method ?
-
fixed operating cost $156,917 per mouth, variable operating cost $16583, average price $90 what is the breakeven point?
-
8. What is the difference between: (15%) a. Explain how open hash tables handle collisions? b. Explain how closed hash tables handle collisions? c. What is the difference between linear probing and...
-
1. Draw the major product of the following reactions. 1 Br2 -78 C HCI 40 C 1 Cl2 65 C 2. Propose a mechanism for the second reaction in problem 1.
-
Refer to the table to answer the following questions. Year Nominal GDP (in billions) Total Federal Spending (in billions) Real GDP (in billions) Real Federal Spending (in billions) 2000 9,817 578...
-
Suppose that a node x is inserted into a red-black tree with RB-INSERT and then is immediately deleted with RB-DELETE. Is the resulting red-black tree the same as the initial red-black tree? Justify...
-
Show that the constraints in line (35.19) are redundant in the sense that if we remove them from the linear program in lines (35.17)-(35.20), any optimal solution to the resulting linear program must...
-
Give three feasible solutions to the linear program in (29.24)(29.28). What is the objective value of each one?
-
Cruz Manufacturing Ltds sales slumped badly in 2019. For the first time in its history, it operated at a loss. The companys income statement showed the following results from selling 600 000 units of...
-
The following are emails from various students to Dr. Destiny Sands, who is a professor in the English Department. These students are wondering if Dr. Sands would let them register for her...
-
What are some flawed assumptions about workplace communication? What is the reality for each myth?
Study smarter with the SolutionInn App