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 test cases:
HeapsortA as array
BuildMaxHeapA
for i n to
swap A Ai
n n
HeapifyA
BuildMaxHeap A as array
n elementsin A
for i floor n to
HeapifyAi
HeapifyA as array, i as int
left i
right i
if leftn and Aleft Ai
max left
else
max i
if right n and ArightAmax
max right
if max i
swapAiAmax
HeapifyA max
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
