-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
103 lines (72 loc) · 4.11 KB
/
Main.java
File metadata and controls
103 lines (72 loc) · 4.11 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import java.util.Arrays;
import java.util.Random;
public class Main {
public static void main(String args[]) {
// Change limits here, be wary of long load times
final int ARRAY_LENGTH = 10;
final int UPPER_BOUND = 1001;
int[] randomArray = new int[ARRAY_LENGTH];
Random r = new Random();
// Filled the array with 10 random integers from 0 to 1000 (with potential for the same number to appear)
for (int count = 0; count < randomArray.length; count++) {
randomArray[count] = r.nextInt(UPPER_BOUND); // Default is [0...1000]
}
System.out.println("------------------");
System.out.println("QUADRATIC SORTS ");
System.out.println("------------------");
BubbleSort bubbleSort = new BubbleSort();
bubbleSort.sort(Arrays.copyOf(randomArray, randomArray.length));
BucketSort bucketSort = new BucketSort();
bucketSort.sort(Arrays.copyOf(randomArray, randomArray.length));
CocktailSort cocktailSort = new CocktailSort();
cocktailSort.sort(Arrays.copyOf(randomArray, randomArray.length));
CombSort combSort = new CombSort();
combSort.sort(Arrays.copyOf(randomArray, randomArray.length));
CycleSort cycleSort = new CycleSort();
cycleSort.sort(Arrays.copyOf(randomArray, randomArray.length));
GnomeSort gnomeSort = new GnomeSort();
gnomeSort.sort(Arrays.copyOf(randomArray, randomArray.length));
InsertionSort insertionSort = new InsertionSort();
insertionSort.sort(Arrays.copyOf(randomArray, randomArray.length));
OddEvenSort oddEvenSort = new OddEvenSort();
oddEvenSort.sort(Arrays.copyOf(randomArray, randomArray.length));
PancakeSort pancakeSort = new PancakeSort();
pancakeSort.sort(Arrays.copyOf(randomArray, randomArray.length));
RecursiveBubbleSort recursiveBubbleSort = new RecursiveBubbleSort();
recursiveBubbleSort.sort(Arrays.copyOf(randomArray, randomArray.length));
SelectionSort selectionSort = new SelectionSort();
selectionSort.sort(Arrays.copyOf(randomArray, randomArray.length));
ShellSort shellSort = new ShellSort();
shellSort.sort(Arrays.copyOf(randomArray, randomArray.length));
System.out.println("");
System.out.println("------------------");
System.out.println("QUASILINEAR SORTS");
System.out.println("------------------");
HeapSort heapSort = new HeapSort();
heapSort.sort(Arrays.copyOf(randomArray, randomArray.length));
IterativeQuickSort iterativeQuickSort = new IterativeQuickSort();
iterativeQuickSort.sort(Arrays.copyOf(randomArray, randomArray.length));
MergeSort mergeSort = new MergeSort();
mergeSort.sort(Arrays.copyOf(randomArray, randomArray.length));
QuickSort quickSort = new QuickSort();
quickSort.sort(Arrays.copyOf(randomArray, randomArray.length));
System.out.println("");
System.out.println("------------------");
System.out.println("NON BOUNDED SORTS ");
System.out.println("------------------");
RadixSort radixSort = new RadixSort();
radixSort.sort(Arrays.copyOf(randomArray, randomArray.length));
System.out.println("");
System.out.println("------------------");
System.out.println("EXTRAS & INFINITE SORTS ");
System.out.println("------------------");
BinaryInsertionSort binaryInsertionSort = new BinaryInsertionSort();
binaryInsertionSort.sort(Arrays.copyOf(randomArray, randomArray.length));
BogoSort bogoSort = new BogoSort();
System.out.println("BogoSort: " + "Uncomment to Activate");
//bogoSort.sort(Arrays.copyOf(randomArray, randomArray.length));
StoogeSort stoogeSort = new StoogeSort();
System.out.println("StoogeSort: " + "Uncomment to Activate. Works fine with smaller array, has serious issues with big arrays");
//stoogeSort.sort(Arrays.copyOf(randomArray, randomArray.length));
}
}