-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInsertionSortTest.java
More file actions
23 lines (22 loc) · 1.06 KB
/
Copy pathInsertionSortTest.java
File metadata and controls
23 lines (22 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.Arrays;
import java.util.Random;
public class InsertionSortTest {
public static void main(String[] args) {
Integer[] easyArray = {1, 2, 3, 4, 5, 6, 7, 8, 9};
System.out.printf("Original array: %s%n%n", Arrays.toString(easyArray));
InsertionSort.insertionSort(easyArray);
System.out.printf("%nSorted array: %s%n", Arrays.toString(easyArray));
Integer[] hardArray = {9, 8, 7, 6, 5, 4};
System.out.printf("Original array: %s%n%n", Arrays.toString(hardArray));
InsertionSort.insertionSort(hardArray);
System.out.printf("%nSorted array: %s%n", Arrays.toString(hardArray));
Integer[] randomArray = new Integer[9];
for(int i = 0; i < randomArray.length; i++) {
Random random = new Random();
randomArray[i] = random.nextInt(99);
}
System.out.printf("Original array: %s%n%n", Arrays.toString(randomArray));
InsertionSort.insertionSort(randomArray);
System.out.printf("%nSorted array: %s%n", Arrays.toString(randomArray));
}
}