Question: Revise the code for selectionSort in such a way that the program selects the next largest (instead of the next smallest) entry in the array

Revise the code for selectionSort in such a way that the program selects the next largest (instead of the next smallest) entry in the array and sorts the array into ascending order.

For example, If the input array is 9 7 3 4 1 8 6 2

Pass 1: 2 7 3 4 1 8 6 9 (the largest element (9) is in its final location)

Pass 2: 2 7 3 4 1 6 8 9 (the next largest element (8) is in its final location)

Pass 3: 2 6 3 4 1 7 8 9 (the next largest element (7) is in its final location

Etc. 2.

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!