Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need detailed explanation. USE C language. Dont use chat GPT. Thanks Analysis of Algorithm Heaps with links In class we showed how heaps can be
Need detailed explanation. USE C language. Dont use chat GPT. Thanks
Analysis of 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.
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