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 (somewhat) efficient sorting algorithm that works by repeatedly selecting the smallest element (or largest if you are sorting from greatest to least) 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 Lab11Demo 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. Your time taken in ms will also be slightly different due to computer hardware

Grading (10 points)