Lab 11: Sorting (Selection Sort)

Due Date and Submission Requirements


The goal of this lab is:


Directions

Using Lab11Demo.java as a starting point, you will fill in the body of the selection_sort method so that it sorts a given array using the Selection Sort algorithm. This method has one argument (an unsorted array), and returns a sorted array.


Selection sort is a simple and efficient sorting algorithm that works by repeatedly selecting the smallest (or largest) element from the unsorted portion of the list and moving it to the sorted portion of the list. The algorithm repeatedly selects the smallest (or largest) element from the unsorted portion of the list and swaps it with the first element of the unsorted portion. This process is repeated for the remaining unsorted portion of the list until the entire list is sorted.

If selection sort still does not make sense, you should watch this video.

You are NOT allowed to modify the Lab10Demo class other than the code inside of the selection_sort method.

Starting Code

Output

When you run your program, your output should look something like this: sample output. Because random numbers are used, your output will be different, but your array should be sorted after calling the selection_sort method.

Grading (10 points)