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
-
Workshop 8: Prioritization Matrix The tools practiced in this workshop are: Brainstorming Prioritization matrix Situation: Consider that you/your group works for a call center for an insurance...
-
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
-
What is an isomer?
-
How do economists use the multiplier?
-
Do you think that private foundations should encourage and be allowed to fund lobbying activities? Why or why not?
-
San Mateo Health Care Inc. is owned and operated by Rachel Fields, the sole stockholder. During January 20Y6, San Mateo Health Care entered into the following transactions: Jan. 1 Received $27,000...
-
Find the volume of the solid obtained by rotating the region bounded by the given curves about the specified line.xy = 1 , y = 0 , x = 1 , x = 2 about x = 2
-
George Pharmacy is a pharmaceutical salesman who has been very successful at his job in the last few years. Unfortunately, his family life has not been very happy. Three years ago, his only child,...
-
1. Consider two particles Aand A2 that are connected to each other by a rigid massless rod of length 1 m. Their masses are 2m kg and m kg, respectively. Suppose that they are undergoing a rectilinear...
-
Drafting a Simple Business Contract Background You are the business owner. You offer sitter services for elderly. Your client has 85 yr old healthy dad who needs a companion from 1-5 pm, 5 days a...
-
Based on the info below, which constraint Matrix A has the dimensions 54 and Matrix B has the dimensions 51, What are the dimensions of the product AB? a. A Matrix of 4x4 b. multiplication is not...
-
The term "provision" as it is used in IAS 37, is most closely related to what term in U.S. GAAP? O Contingent liability, where the outflow of resources is "remote." Contingent liability, where the...
-
Provide an assessment of the potential competitive advantage afforded to DHL's proximity to seaport cities such as Durban and Cape Town. Your assessment must take into account the logistics...
-
Assume that SJM will bid on job 1 0 1 that has the following requirements: Mining Processing Machine hours 2 0 0 1 5 0 Labor hours 1 0 0 2 2 5 Assume further that job 1 0 1 has prime costs of $ 3 , 0...
-
Sharp Company manufactures a variety of electric razors for men and women. The company's plant is partially automated. Listed below is cost driver information used in the product-costing system:...
-
Tarick Toys Company manufactures video game consoles and accounts for product costs using process costing. The following information is available regarding its June inventories. The following...
-
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?
-
Porter Manufacturing Company uses the perpetual inventory system to account for its manufacturing inventories. The following are Porters transactions during September 2019: Sept. 5 Received materials...
-
James Alvarez, an engineer, needs some accounting advice. In their spare time during the past year, Alvarez and his college-aged son, Robert, have manufactured a small weed-trimming sickle in a...
-
Apple's 2017 Environmental Responsibility Report can be found at the following link: http://www.images.apple.com/environment/reports/docs/apple_environmental_responsibility_report_0714.pdf Skim this...
Study smarter with the SolutionInn App