Run the iterative version of the selection sort algorithm on
Solution
Run the iterative version of the selection sort algorithm on an array containing elements:
 34   72   81   19   27   36   50
The algorithm for selection sort in simple terms is:
 For i = 1 : n-1
    Select the largest of first n-i+1 elements.
    Exchange the largest element with (n-i+1)th element.
 Here n value is: 7.
 So, the sorting goes like this:
i = 1: Select the largest of first 7 elements. i.e., 81. Exchange with 7th element.
 [34   72   50   19   27   36   81]
i = 2: Select the largest of first 6 elements. i.e., 72. Exchange with 6th element.
 [34   36   50   19   27   72]   81
i = 3: Select the largest of first 5 elements. i.e., 50. Exchange with 5th element.
 [34   36   27   19   50]   72   81
i = 4: Select the largest of first 4 elements. i.e., 36. Exchange with 4th element.
 [34   19   27   36]   50   72   81
i = 5: Select the largest of first 3 elements. i.e., 34. Exchange with 3rd element.
 [27   19   34]   36   50   72   81
i = 6: Select the largest of first 2 elements. i.e., 27. Exchange with 2nd element.
 [19   27]   34   36   50   72   81
Exit the loop. So, now the sorted list is:
 19   27   34   36   50   72   81

