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
Get step-by-step solutions from verified subject matter experts
