-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDriver.java
160 lines (116 loc) · 5.04 KB
/
Driver.java
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import java.util.ArrayList;
public class Driver{
public static void main(String[] args){
//testing bubbleSort
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println("Testing bubbleSort:");
System.out.println("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
ArrayList<Comparable> test1 = new ArrayList<Comparable>();
for(int i = 0; i < 100; i++){
test1.add(i);
}
//ordered from least to greatest
System.out.println("Testing bubbleSort with " + test1.size() + " elements from least to greatest:");
System.out.println("Array before sorting: " );
System.out.println(test1);
Sorts.bubbleSortV(test1);
System.out.println("Array after sorting: ");
System.out.println(test1);
ArrayList<Comparable> test2 = new ArrayList<Comparable>();
for(int i = 99; i > -1; i--){
test2.add(i);
}
//ordered from greatest to least
System.out.println("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println("Testing bubbleSort with " + test2.size() + " elements from greatest to least:");
System.out.println("Array before sorting: " );
System.out.println(test2);
Sorts.bubbleSortV(test2);
System.out.println("Array after sorting: ");
System.out.println(test2);
//random order
for(int i = 0; i < 100; i++){
Sorts.shuffle(test1);
System.out.println("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println("Testing bubbleSort with " + test1.size() + " elements in random order:");
System.out.println("Array before sorting: " );
System.out.println(test1);
Sorts.bubbleSortV(test1);
System.out.println("Array after sorting: ");
System.out.println(test1);
}
//testing selectionSort
System.out.println("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println("Testing selectionSort:");
System.out.println("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
test1 = new ArrayList<Comparable>();
for(int i = 0; i < 100; i++){
test1.add(i);
}
System.out.println("Testing selectionSort with " + test1.size() + " elements from least to greatest:");
System.out.println("Array before sorting: " );
System.out.println(test1);
Sorts.selectionSortV(test1);
System.out.println("Array after sorting: ");
System.out.println(test1);
test2 = new ArrayList<Comparable>();
for(int i = 99; i > -1; i--){
test2.add(i);
}
System.out.println("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println("Testing selectionSort with " + test2.size() + " elements from greatest to least:");
System.out.println("Array before sorting: " );
System.out.println(test2);
Sorts.selectionSortV(test2);
System.out.println("Array after sorting: ");
System.out.println(test2);
for(int i = 0; i < 100; i++){
Sorts.shuffle(test1);
System.out.println("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println("Testing selectionSort with " + test1.size() + " elements in random order:");
System.out.println("Array before sorting: " );
System.out.println(test1);
Sorts.selectionSortV(test1);
System.out.println("Array after sorting: ");
System.out.println(test1);
}
//testing insertionSort
System.out.println("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println("Testing insertionSort:");
System.out.println("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
test1 = new ArrayList<Comparable>();
for(int i = 0; i < 100; i++){
test1.add(i);
}
//ordered from least to greatest
System.out.println("Testing insertionSort with " + test1.size() + " elements from least to greatest:");
System.out.println("Array before sorting: " );
System.out.println(test1);
Sorts.insertionSortV(test1);
System.out.println("Array after sorting: ");
System.out.println(test1);
test2 = new ArrayList<Comparable>();
for(int i = 99; i > -1; i--){
test2.add(i);
}
//ordered from greatest to least
System.out.println("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println("Testing insertionSort with " + test2.size() + " elements from greatest to least:");
System.out.println("Array before sorting: " );
System.out.println(test2);
Sorts.insertionSortV(test2);
System.out.println("Array after sorting: ");
System.out.println(test2);
//random order
for(int i = 0; i < 100; i++){
Sorts.shuffle(test1);
System.out.println("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println("Testing insertionSort with " + test1.size() + " elements in random order:");
System.out.println("Array before sorting: " );
System.out.println(test1);
Sorts.insertionSortV(test1);
System.out.println("Array after sorting: ");
System.out.println(test1);
}
}
}