Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++: Write a heapsort program that generates random numbers and insert them in h

ID: 3568684 • Letter: C

Question

C++: Write a heapsort program that generates random numbers and insert them in heap. The

program then performs heapsort to sort the numbers in ascending order. Implement the heap

using an array and compare its performance to STL heap implementation.

Requirements:

1. Use random number generator to generate integers numbers in range [0..1000]. Your

program should prompt the user for the total number of numbers to generate. A listing

of the generated numbers should be printed on screen in the order they are generated.

Allocate a dynamic array to store the numbers.

2. Construct the heap by performing the heapify algorithm.

3. Once the heap is constructed, perform heapsort algorithm and display the sorted list on

screen.

4. Use STL heap algorithms to redo Steps 1-3. Take the times of both implementations.

However, exclude the times for printing numbers on screen. Display the times of both

implementations on screen.

5. Prompt the user whether he/she wants to work on another list of numbers and repeat

Step 1-4 if the user answers

Explanation / Answer

#include #include int heapSize = 1000; void print(int a[]) { for (int i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote