-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
285 lines (247 loc) · 8.97 KB
/
main.cpp
File metadata and controls
285 lines (247 loc) · 8.97 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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#include "utility_functions.cpp"
#include "bubble_sort.cpp"
#include "headers.cpp"
#include "heap_sort.cpp"
#include "insertion_sort.cpp"
#include "merge_sort.cpp"
#include "quick_sort.cpp"
#include "selection_sort.cpp"
#include <algorithm>
#include <chrono>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
using namespace std::chrono;
// Main Function
int main() {
// TASK 1 OUTPUT
cout << "=========TASK 1==============\n";
for (int i = 0; i <= 7; i++) {
// Initialization and printArray
Size = dataSetSizes[i];
cout << "Current Size:" << Size << endl;
int *tempArr = newPermutArray(Size);
cout << "Original Array:\n";
printArray(tempArr, Size);
// BUBBLE SORT
cout << "=======BUBBLE SORT:============\n";
cout << "Bubble Sort A = ";
func_eval(tempArr, Size, bubbleSortA);
bubbleSortAS(tempArr, Size);
cout << "Bubble Sort B = ";
func_eval(tempArr, Size, bubbleSortB);
bubbleSortBS(tempArr, Size);
// INSERTION SORT
cout << "=======INSERTION SORT:============\n";
cout << "Insertion Sort A = ";
func_eval(tempArr, Size, insertionSortA);
insertionSortAS(tempArr, Size);
cout << "Insertion Sort B = ";
func_eval(tempArr, Size, insertionSortB);
insertionSortBS(tempArr, Size);
// SELECTION SORT
cout << "=======SELECTION SORT:============\n";
cout << "Selection Sort A = ";
func_eval(tempArr, Size, selectionSortA);
selectionSortAS(tempArr, Size);
cout << "Selection Sort B = ";
func_eval(tempArr, Size, selectionSortB);
selectionSortBS(tempArr, Size);
// HEAP SORT
cout << "=======HEAP SORT:================\n";
cout << "Heap Sort A = ";
func_eval(tempArr, Size, heapSortA);
heapSortAS(tempArr, Size);
cout << "Heap Sort B = ";
func_eval(tempArr, Size, heapSortB);
heapSortBS(tempArr, Size);
// MERGESORT
cout << "=======MERGESORT:================\n";
cout << "Merge Sort A = ";
func_eval2(tempArr, 0, Size - 1, mergeSortA);
func_evalStepsMQ(tempArr, 0, Size - 1, mergeSortAS);
cout << "Merge Sort B = ";
func_eval2(tempArr, 0, Size - 1, mergeSortB);
func_evalStepsMQ(tempArr, 0, Size - 1, mergeSortBS);
// Merge Insertion
cout << "Merge-Insertion Sort A = ";
func_evalMergeIns(tempArr, 0, Size - 1, Size * 0.01, mergeInsertionSortA);
func_evalMergeInsSteps(tempArr, 0, Size - 1, Size * 0.01,
mergeInsertionSortAS);
cout << "Merge-Insertion Sort B = ";
func_evalMergeIns(tempArr, 0, Size - 1, Size * 0.01, mergeInsertionSortB);
func_evalMergeInsSteps(tempArr, 0, Size - 1, Size * 0.01,
mergeInsertionSortBS);
// QUICKSORT
cout << "=======QUICKSORT:================\n";
// Hoarse
cout << "Quick Sort A (HOARSE)= ";
func_eval2(tempArr, 0, Size - 1, quickSortHA);
func_evalStepsMQ(tempArr, 0, Size - 1, quickSortHAS);
cout << "Quick Sort B (HOARSE)= ";
func_eval2(tempArr, 0, Size - 1, quickSortHB);
func_evalStepsMQ(tempArr, 0, Size - 1, quickSortHBS);
// Lamuto
cout << "Quick Sort A (LAMUTO)= ";
func_eval2(tempArr, 0, Size - 1, QuicksortLA);
func_evalStepsMQ(tempArr, 0, Size - 1, QuicksortLAS);
cout << "Quick Sort B (LAMUTO)= ";
func_eval2(tempArr, 0, Size - 1, QuicksortLB);
func_evalStepsMQ(tempArr, 0, Size - 1, QuicksortLBS);
delete[] tempArr;
BaseArr.clear();
}
return 0;
}
/* DEMO
1.
for(int i = 1; i < 2; i++){
Size = dataSetSizes[i];
cout << "Current Size:" << Size << endl;
int *tempArr = newPermutArray(Size);
cout << "Original Array:\n";
printArray(tempArr, Size);
}
2.
// TASK 1 OUTPUT
cout << "=========TASK 1==============\n";
for (int i = 0; i <= 7; i++) {
// Initialization and printArray
Size = dataSetSizes[i];
cout << "Current Size:" << Size << endl;
int *tempArr = newPermutArray(Size);
// cout << "Original Array:\n";
// printArray(tempArr, Size);
// // BUBBLE SORT
// cout << "=======BUBBLE SORT:============\n";
// cout << "Bubble Sort A = ";
// func_eval(tempArr, Size, bubbleSortA);
// bubbleSortAS(tempArr, Size);
// cout << "Bubble Sort B = ";
// func_eval(tempArr, Size, bubbleSortB);
// bubbleSortBS(tempArr, Size);
// // INSERTION SORT
// cout << "=======INSERTION SORT:============\n";
// cout << "Insertion Sort A = ";
// func_eval(tempArr, Size, insertionSortA);
// insertionSortAS(tempArr, Size);
// cout << "Insertion Sort B = ";
// func_eval(tempArr, Size, insertionSortB);
// insertionSortBS(tempArr, Size);
// SELECTION SORT
cout << "=======SELECTION SORT:============\n";
cout << "Selection Sort A = ";
func_eval(tempArr, Size, selectionSortA);
selectionSortAS(tempArr, Size);
cout << "Selection Sort B = ";
func_eval(tempArr, Size, selectionSortB);
selectionSortBS(tempArr, Size);
// HEAP SORT
cout << "=======HEAP SORT:================\n";
cout << "Heap Sort A = ";
func_eval(tempArr, Size, heapSortA);
heapSortAS(tempArr, Size);
cout << "Heap Sort B = ";
func_eval(tempArr, Size, heapSortB);
heapSortBS(tempArr, Size);
// MERGESORT
cout << "=======MERGESORT:================\n";
cout << "Merge Sort A = ";
func_eval2(tempArr, 0, Size - 1, mergeSortA);
func_evalStepsMQ(tempArr, 0, Size - 1, mergeSortAS);
cout << "Merge Sort B = ";
func_eval2(tempArr, 0, Size - 1, mergeSortB);
func_evalStepsMQ(tempArr, 0, Size - 1, mergeSortBS);
// Merge Insertion
cout << "Merge-Insertion Sort A = ";
func_evalMergeIns(tempArr, 0, Size - 1, Size * 0.01, mergeInsertionSortA);
func_evalMergeInsSteps(tempArr, 0, Size - 1, Size * 0.01,
mergeInsertionSortAS);
cout << "Merge-Insertion Sort B = ";
func_evalMergeIns(tempArr, 0, Size - 1, Size * 0.01, mergeInsertionSortB);
func_evalMergeInsSteps(tempArr, 0, Size - 1, Size * 0.01,
mergeInsertionSortBS);
// QUICKSORT
cout << "=======QUICKSORT:================\n";
// Hoarse
cout << "Quick Sort A (HOARSE)= ";
func_eval2(tempArr, 0, Size - 1, quickSortHA);
func_evalStepsMQ(tempArr, 0, Size - 1, quickSortHAS);
cout << "Quick Sort B (HOARSE)= ";
func_eval2(tempArr, 0, Size - 1, quickSortHB);
func_evalStepsMQ(tempArr, 0, Size - 1, quickSortHBS);
// Lamuto
cout << "Quick Sort A (LAMUTO)= ";
func_eval2(tempArr, 0, Size - 1, QuicksortLA);
func_evalStepsMQ(tempArr, 0, Size - 1, QuicksortLAS);
cout << "Quick Sort B (LAMUTO)= ";
func_eval2(tempArr, 0, Size - 1, QuicksortLB);
func_evalStepsMQ(tempArr, 0, Size - 1, QuicksortLBS);
delete[] tempArr;
BaseArr.clear();
}
3.
// PART 2
cout << "=========TASK 2==============\n";
for (int i = 0; i < 8; i++)
{
Size = dataSetSizes[i];
cout << "\n\n\nCurrent Size: " << Size << endl
<< endl;
for (int j = 1; j <= 50; j++)
{
int *tempArr = newRandArray(Size);
// // BUBBLE SORT
// cout << "=======BUBBLE SORT:============\n";
// cout << "Time\n";
// func_eval(tempArr, Size, bubbleSortA);
// cout << "Steps\n";
// bubbleSortAS(tempArr, Size);
// // INSERTION SORT
// cout << "=======INSERTION SORT:============\n";
// cout << "Time\n";
// func_eval(tempArr, Size, insertionSortA);
// cout << "Steps\n";
// insertionSortAS(tempArr, Size);
// // SELECTION SORT
// cout << "=======SELECTION SORT:============\n";
// cout << "Time\n";
// func_eval(tempArr, Size, selectionSortA);
// cout << "Steps\n";
// selectionSortAS(tempArr, Size);
// HEAP SORT
cout << "=======HEAP SORT:============\n";
cout << "Time\n";
func_eval(tempArr, Size, heapSortA);
cout << "Steps\n";
heapSortAS(tempArr, Size);
// MERGE SORT
cout << "=======MERGE SORT:============\n";
cout << "Time\n";
func_eval2(tempArr, 0, Size - 1, mergeSortA);
cout << "Steps\n";
func_evalStepsMQ(tempArr, 0, Size - 1, mergeSortAS);
// MERGE-Insertion SORT
cout << "=======MERGE INSERTION SORT:============\n";
cout << "Time\n";
func_evalMergeIns(tempArr, 0, Size - 1, Size * 0.01, mergeInsertionSortA);
cout << "Steps\n";
func_evalMergeInsSteps(tempArr, 0, Size - 1, Size * 0.01, mergeInsertionSortAS);
// QUICKSORT SORT HOARSE
cout << "=======QUICK SORT HOARSE:============\n";
cout << "Time\n";
func_eval2(tempArr, 0, Size - 1, quickSortHA);
cout << "Steps\n";
func_evalStepsMQ(tempArr, 0, Size - 1, quickSortHAS);
// QUICKSORT SORT LAMUTO
cout << "=======QUICK SORT LAMUTO:============\n";
cout << "Time\n";
func_eval2(tempArr, 0, Size - 1, QuicksortLA);
cout << "Steps\n";
func_evalStepsMQ(tempArr, 0, Size - 1, QuicksortLAS);
delete[] tempArr;
BaseArr.clear();
}
}
*/