Question: Task: Implement a heap as a contiguous list and then use heapsort on the list. Create Three Files 1) Header file .h 2) Implemantation file

Task: Implement a heap as a contiguous list and then use heapsort on the list.

Create Three Files 1) Header file .h 2) Implemantation file .cpp 3) demo file .cpp

Data Structure: Use an array to store the list. However, do not use the built-in STL functions for a heap -- i.e., do not use make_heap( ), push_heap( ), pop_heap( ), or sort_heap( ).

Processing: Do the following operations:

1) Fill an array with unordered integers, from the text.txt file. You may assume that the input list has no duplicate entries.

2) Convert the original list into a heap using Nyhoffs heapify algorithm.

3) Sort the heap with a heapsort.

Output: Print the list 3 times

1) After the initial load

2) After converting to a heap

3) After sorting

4) The output may go to the screen.

text.txt: 72, 85, 9, 307, 25, 506, 182, 175, 10, 64, 430, 399, 2, 71, 90, 55, 471, 250, 18, 222, 49, 103, 550, 341, 273

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!