Question: Task: Implement a heap as a contiguous list and then use heapsort on the list. Data Structure : Use an array to store the list.
Task: Implement a heap as a contiguous list and then use heapsort on the list.
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:
Fill an array with unordered integers, from the C162P10heaplist.txt file. You may assume that the input list has no duplicate entries.
Convert the original list into a heap using Nyhoffs heapify algorithm.
Sort the heap with a heapsort.
Output: Print the list 3 times
after the initial load
after converting to a heap
after sorting
The output may go to the screen.
C162P10heaplist.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
Get step-by-step solutions from verified subject matter experts
