Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Business Process Driven Database Design With Oracle PL SQL

Authors: Rajeev Kaula

1st Edition

1795532386, 978-1795532389

More Books

Students also viewed these Databases questions