Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this problem, you are asked to demonstrate the execution of the Heapsort algorithm on the following array: A = [5, 8, 2, 6, 3,

image text in transcribed

In this problem, you are asked to demonstrate the execution of the Heapsort algorithm on the following array: A = [5, 8, 2, 6, 3, 1, 4, 7] First, consider building the initial heap, where we insert each number one at a time into a heap (that is initially empty). Show the heap after each insert. Second, consider the for loop where we sort the array A. Show the status of the heap after each Extract-Max. In class we showed how heaps can be implemented using an array. In this problem we consider using an implementation using pointers. Consider storing a heap as a linked binary tree with pointers. Give pseudocode 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? 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? Which of the three heap implementations (array, linked tree, linked list) is preferable? Justify your answer. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

0201844524, 978-0201844528

More Books

Students also viewed these Databases questions

Question

b. Explain how you initially felt about the communication.

Answered: 1 week ago