Question: Read the following Heap Sort function and determine the correct answer for blank #3. template void HeapSort(ItemType values[], int numValues) // Pre: Struct HeapType is
Read the following Heap Sort function and determine the correct answer for blank #3.
template
void HeapSort(ItemType values[], int numValues)
// Pre: Struct HeapType is available.
// Post: The elements in the array values are sorted by key.
{
int index;
// Convert the array of values into a heap.
for (index = ___________; index >= 0; index--) // 1
_________(values, index, numValues-1); // 2
// Sort the array.
for (index = numValues-1; index >=1; index--)
{
Swap(___________, values[index]); // 3
__________(values, 0, index-1); // 4
}
}
A) values[numValues-1]
B) values[0]
C) values[1]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
