Question: [ Sorting: 1 5 % ] Answer two questions regarding to the stable property of sorting. ( a ) ( 8 % ) Show how
Sorting: Answer two questions regarding to the stable property of sorting.
a Show how to detect a sorting algorithm is stable or not. That is given an unknown sorting algorithm, can you help to write a short script to detect whether the output of the sorting algorithm produces stable outcomes.
b Below is an implementation of the heapsort algorithm. Can you identify the lines where executing the lines can lead to nonstable sorting result, and why?
MAXHEAPIFY
LEFT
RIGHT
if heapsize A and
then largest larrl
else largest larri
if heapsize A and largest
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
