Question: Write a python code to sort an array A in ascending order with below pseudocode and include 5 test cases: _ _ _ _ _

Write a python code to sort an array A in ascending order with below pseudocode and include 5 test cases:
_____________________________________________
Heapsort(A as array)
BuildMaxHeap(A)
for i = n to 1
swap (A[1], A[i])
n = n-1
Heapify(A,1)
BuildMaxHeap (A as array)
n = elements_in (A)
for i = floor (n/2) to 1
Heapify(A,i)
Heapify(A as array, i as int)
left =2i
` right =2i +1
if (left<=n) and (A[left]> A[i])
max = left
else
max = i
if (right <=n) and (A[right]>A[max])
max = right
if (max != i)
swap(A[i],A[max])
Heapify(A, max)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!