CISC 1115
Introduction to Programming Using Java
Lab #15
Sorting and Searching

How to Develop and Submit your Labs

Lab 15.1 — Largest Element Selection Sort (SelectionSort)

The selection sort presented in class repeatedly found smallest elements of the remaining values to be sorted and placed them in successive positions beginning at 0 and moving forward through the array. An equivalent approach is to successively find the largest elements and place them in the array beginning at the last element and moving backward through the array.

Code this second version of selection sort.

Sample Test Run

For example if the file numbers.text contains:

6
2
6
3
4
1
5
the program should produce the following output:
Initial: {2, 6, 3, 4, 1, 5}
Pass #1: {2, 5, 3, 4, 1, 6}
Pass #2: {2, 1, 3, 4, 5, 6}
Pass #3: {2, 1, 3, 4, 5, 6}
Pass #4: {2, 1, 3, 4, 5, 6}
Pass #5: {1, 2, 3, 4, 5, 6}
Pass #6: {1, 2, 3, 4, 5, 6}
Sorted: {1, 2, 3, 4, 5, 6}