Need detailed explanation. USE C language. Dont use chat GPT. Thanks Analysis of Algorithm Heaps with links
Fantastic news! We've Found the answer you've been seeking!
Question:
Need detailed explanation. USE C language. Dont use chat GPT. Thanks
Analysis of Algorithm
Transcribed Image Text:
Heaps with links In class we showed 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. Heaps with links In class we showed 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
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...
-
What types of costs are associated with a Stance" sock vending machine located in an airport? At Cleveland Hopkins International Airport in northeastern Ohio, a vending machine that dispenses socks...
-
Which of the following is correct regarding the deduction for self-employment taxes? a. Self-employment taxes are deductible in full to arrive at adjusted gross income b. Self-employment taxes are...
-
Figure Q20.14 shows a pattern formed by snow on the roof of a barn. What causes the alternating pattern of snow-covered and exposed roof? Coutesy of Dr. Aibe t A Bardet, hiesiyetColorade, Boulder 0
-
Refer to the table developed in problem 15.5 for University Health Center. Assume the Managed Care Division is evaluating a project with the net cash flows and probabilities shown in the table below....
-
1. Should there be additional overtime, and if so, how much? 2. Should additional laminate be purchased, and if so, how much? 3. Should additional wood be purchased, and if so, how much? 4. What is...
-
Explain the issues that an auditor may need to deal with in the cash accounts, especially if the company has foreign bank accounts for international transactions. Also, would a schedule of interbank...
-
Error Analysis Margo is comparing the functions f(x)=|x| and g(x)=|x+1|-5. She said the graph of g is a vertical translation of the graph of f^(5) units down and a horizontal translation of the graph...
-
You have been asked by a supermarket chain to propose suitable packaging and labeling for a range of snack food products such as chocolate chip cookies, ginger snaps, crackers, peanut butter cookies,...
-
Outline the importance of country of origin as a brand element.
-
How do the media options available to advertisers vary in different parts of the world? What can advertisers do to cope with media limitations in certain countries?
-
Explain direct marketings advantages and identify the most common types of direct marketing channels.
-
Identify and compare the basic structure options for consumer channels and industrial channels.
-
Let p , q , and r represent the ff statements: p : Chloe went to school. q : Her mom washed the dishes after dinner. r : Alfred made a surprise gift. Write the symbolic form of this statement:...
-
The Cholesterol Level data sets give cholesterol levels of heart attack patients. Cholesterol measures are taken 2, 4, and 14 days aft er a patient has suffered a heart attack. Is there a significant...
-
Analyze Sears, using the competitive forces and value chain models.
-
What was the problem at Celcom that was described this case? What people, organization, and technology factors contributed to this problem?
-
How do information systems help businesses compete using quality and design? a. Define quality and compare the producer and consumer definitions of quality. b. Describe the various ways in which...
-
Let us consider a European-style put option on a non-dividend-paying asset whose price follows a GBM with drift 10% and volatility 40% (annualized). The risk-free rate is 5% with continuous...
-
Consider a European-style derivative, depending on ST , the price of a non-dividend-paying stock share at time T, characterized by the payoff depicted in the figure below. 15 5 Payoff 10 20 20 30 35...
-
An investment bank offers a derivative whose payoff at maturity T is given by S 2 T , where ST is the price of the underlying asset, a non-dividendpaying stock share with a price following a GBM....
Study smarter with the SolutionInn App