Question: In C++ please Heap Sort: Here is the pseudocode for Heap Sort, modified to include a counter: count - 0 HeapSort (A) 1 Build Max

In C++ please
Heap Sort: Here is the pseudocode for Heap Sort, modified to include a counter: count - 0 HeapSort (A) 1 Build Max Heap (A) 2 for i-length [A] downto 2 do exchange A[1] - A[i] 4 heap-size [A] - heap-size (A) - 1 5 Max_Heapify (A, 1) And here is the algorithm for the Build_Max_Heap function used by Heap Sort: Build_Max_Heap (A) 1 heap-size [A] - length [A] 2 for i - floor (length [A]/2) downto 1 do 3 Max_Heapify (A, i) 3 And here is the algorithm for the Max_Heapify function used by Heap Sort: Max Heapify (A, i) 1 1-LEFT (i) 2 - RIGHT (i) 3 if is heap-size [A] and A[1] > A[i] 4 then largest - 1 5 else largest - i 6 if r s heap-size [A] and A[r] > A[largest) 7 then largest - I 8 if largest i 9 then exchange A[i] - A[largest] 9.5 count count + 1 10 Max_Heapify (A, largest) Your program for Heap Sort should have a line of code in it that is equivalent to line 10 in the Max_Heapify pseudocode above. In your program, a global counter should keep track of the number of times this line is executed. Quick Sort: Here is the pseudocode for Quick Sort, modified to include a counter QuickSort (A) 1 Count - O 2 QUICKSORT (A,1, length [A]) Here is the pseudocode for the QUICKSORT function used by Quick Sort: QUICKSORT (A,P,r) 1 if p
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
