Question: [ Sorting: 1 5 % ] Answer two questions regarding to the stable property of sorting. ( a ) ( 8 % ) Show how

[Sorting: 15%] Answer two questions regarding to the stable property of sorting.
(a)(8%) 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)(7%) Below is an implementation of the heapsort algorithm. Can you identify the line(s) where executing the line(s) can lead to non-stable sorting result, and why?
MAX-HEAPIFY (A,i)
,1LEFT(i)
,2rRIGHT(i)
,3 if l heap-size A and A[l]>A[i]
,4 then largest larrl
,5 else largest larri
,6 if r heap-size A and largest
[ Sorting: 1 5 % ] Answer two questions regarding

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 Accounting Questions!