Home Sorting Teach | Sorting Lesson | Sorting Homework |
Sorting/Searching Algorithms - Sorting Homework
A homework on sorting algorithms for AP Computer Science students.
Objective:
- Insertion Sort: Sort an array in ascending order using the Insertion Sort algorithm.
- Selection Sort: Sort an array in ascending order using the Selection Sort algorithm.
import java.util.Arrays;
// Test Array
int[] supplies = {29, 10, 14, 37, 13, 18, 25, 30, 4, 9, 12, 40, 50, 23, 28};
// Insertion Sort
public static void insertionSort(int[] arr) {
// TODO: Implement Insertion Sort
// Sort the array using insertion sort algorithm
System.out.println("Insertion Sort: " + results);
}
// Selection Sort
public static void selectionSort(int[] arr) {
// TODO: Implement Selection Sort
// Sort the array using selection sort algorithm
System.out.println("Selection Sort: " + results);
}
insertionSort(supplies);
selectionSort(supplies);