Question: heapsort ( da: DynamicArray ) - > None: Write a function that receives a DynamicArray and sorts its content in non - ascending order, using
heapsortda: DynamicArray None:
Write a function that receives a DynamicArray and sorts its content in nonascending order,
using the Heapsort algorithm. You must sort the array in place, without creating any data
structures. This function does not return anything.
You may assume that the input array will contain one or more homogeneous elements
either all numbers, or strings, or custom objects, but never a mix of these You do not
need to write checks for these conditions.
The runtime complexity of this implementation must be ON log N If the sort uses an
algorithm other than Heapsort, you will not receive any points for this portion of the
assignment, even if your function passes Gradescope.
Example #:
da DynamicArray
printfBefore: da
heapsortda
printfAfter: da
Output:
Before: DYNARR SizeCap:
After: DYNARR SizeCap:
Example #:
da DynamicArraymonkey 'zebra', 'elephant', 'horse', 'bear'
printfBefore: da
heapsortda
printfAfter: da
Output:
Before: DYNARR SizeCap: monkey zebra, elephant, horse, bear
After: DYNARR SizeCap: zebra monkey, horse, elephant, bear
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
