/SortStep

Sorting exercise. (AP CS)

Primary LanguageJava

Sorting

In this assignment you will write a program that tests 4 different sorting algorithms: Bubble, Selection, Insertion, and Merge sort. You will write a Stopwatch class that uses System.nanotime() to measure the time each algorithm takes to sort 1000, 2000, 4000, and 8000 integers.

Suggested steps to complete this assignment

  1. Fork and clone down this repository.
  2. Run the program. You should see the following output:
    Testing Bubble Sort
    Bubble Sort took 0 microseconds
    Testing Selection Sort
    Selection Sort took 0 microseconds
    Testing Insertion Sort
    Insertion Sort took 0 microseconds
    Testing Merge Sort
    Merge Sort took 0 microseconds
  3. First, use System.nanotime() to complete the Stopwatch class
  4. Then, starting with bubblesort, complete the 4 sorting functions in the Sorts class`
  5. (Note that you do not need to add any code to the SortStep program)
  6. Test each sorting algorithm for the time it takes to sort 1000, 2000, 4000 and 8000 integers, and write your answers on the handout for the assignment. You should run the tests several times and record the best time for each.
  7. When you are finished, submit the sorting handout to the schoolloop drop box. (Note that is not necessary to submit your code for the assignment).
  8. If you have extra time, you might try to improve the efficiency of your merge sort. Also, feel free to add other sorts like quick sort or gnome sort to the program.