Download Sorts.java and SortsStep.java
Rename Sorts.java with your period and name. Ex: P3_Wang_Michael_Sorts.java
Open SortStep.java
and change lines 15 and 23 to match the name you chose in the previous step.
Inside your Sorts
class, write code for the 3 quadratic sorting algorithms.
Instead of copying previous sorting code you wrote earlier, challenge yourself to rewrite each sorting algorithm from scratch. If you really know these algorithms, it won't take long. Leave the merge and mergesort methods blank for now. They will be studied in Lesson A18.
Add the appropriate lines of code to count the number of steps for each algorithm.
Run each of the 3 quadratic sorting algorithms to find out how many steps they take to sort 100, 200, 400 and 800 integers.
Record your results in a data table and corresponding graph. You may do this on paper and submit at the beginning of class or submit a digital version to the Schoology assignment.
100 integers | 200 integers | 400 integers | 800 integers | |
---|---|---|---|---|
BubbleSort | ___ | ___ | ___ | ___ |
SelectionSort | ___ | ___ | ___ | ___ |
InsertionSort | ___ | ___ | ___ | ___ |
PX_LastName_FirstName_Sorts.java
code below. You must Sign In to submit to this assignment
Last modified: January 18, 2023
Back to Lab 17.3 Insertionsort