Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Heap sort is one of the O ( n log n ) sorts we consider. it relies on the idea of maintaining a list so
Heap sort is one of the On log n sorts we consider. it relies on the idea of maintaining a list so that the values exhibit the heap property usually maximum heap then removing one value at a time to sort them.
The program should read in the number of values as an integer, allocate the necessary space, then read in all the values provided. Use a helper function, ReadNums to return the dynamic array, instead of inputting the values in main
Create a function called PrintNums that prints out the array with a space between each value. Finish with a new line.
Complete a function, HeapSort You will need to use one or more helper functions to maintain the heap property through the sorting. Use a minheap to sort the numbers in Descending order.
Ex: When the input is:
the output is:
Unsorted:
Heapified:
Sorted:
LAB: Heap sort
Heap sort is one of the sorts we consider. it relies on the idea of maintaining a list so that the
values exhibit the heap property usually maximum heap then removing one value at a time to sort them.
The program should read in the number of values as an integer, allocate the necessary space, then read
in all the values provided. Use a helper function, ReadNums to return the dynamic array, instead of
inputting the values in main
Create a function called PrintNums that prints out the array with a space between each value. Finish
with a new line.
Complete a function, HeapSort You will need to use one or more helper functions to maintain the
heap property through the sorting. Use a minheap to sort the numbers in Descending order.
Ex: When the input is:
the output is:
Unsorted:
Heapified:
Sorted:
qxzqy
#include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started