-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSortingDriver.java
More file actions
35 lines (28 loc) · 1.24 KB
/
SortingDriver.java
File metadata and controls
35 lines (28 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
public class SortingDriver {
public static <T> void display(T[] array) {
for (int i = 0; i < array.length; i++) {
System.out.print(array[i] + " ");
}
System.out.println();
}
public static <T> void displayCurrent(T[] array) {
System.out.print("Current contents of array: ");
display(array);
System.out.println();
}
public static void main(String[] args) {
Integer[] array1 = {3, 9, 4, 2, 7, 5, 2, 6, 1, 1, 3, 5};
Integer[] array2 = {3, 9, 4, 2, 7, 5, 2, 6, 1, 1, 3, 5};
Integer[] array3 = {3, 9, 4, 2, 7, 5, 2, 6, 1, 1, 3, 5};
//Uncomment each section to showcase array contents during each sorting method
//SelectionSort.selectionSort(array1, array1.length);
//System.out.print("Final contents of array after selection sort: ");
//display(array1);
InsertionSort.insertionSort(array2, 0, array2.length - 1);
System.out.print("Final contents of array after insertion sort: ");
display(array2);
//ShellSort.shellSort(array3, 0, array3.length - 1);
//System.out.print("Final contents of array after insertion sort: ");
//display(array3);
}
}