-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
106 lines (86 loc) · 3.07 KB
/
main.cpp
File metadata and controls
106 lines (86 loc) · 3.07 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
#include <iostream>
#include <string>
#include <algorithm>
#include "SortTestHelper.h"
#include "SelectionSort/selectionSort.h"
#include "InsertionSort/insertionSort.h"
#include "InsertionSort/improveInsertionSort.h"
#include "BubbleSort/bubbleSort.h"
#include "MergeSort/mergeSort.h"
#include "MergeSort/mergeSortBottomToTop.h"
#include "QuickSort/quickSort.h"
#include "QuickSort/quickSortOptimize.h"
#include "QuickSort/quickSortOptimize2.h"
#include "QuickSort/quickSortOptimize3.h"
#include "HeapSort/heapSort.h"
using namespace std;
int main()
{
int n = 1000000;
int * arr = SortTestHelper::generateRandomArray(n, 0, n);
// selection sort
// selectionSort(arr, n);
// SortTestHelper::printArray(arr, n);
// SortTestHelper::testSort("Selection Sort", selectionSort, arr, n);
// insertionSort(arr, n);
// SortTestHelper::printArray(arr, n);
// SortTestHelper::testSort("insertion Sort", insertionSort, arr, n);
// improveInsertionSort(arr, n);
// SortTestHelper::printArray(arr, n);
// SortTestHelper::testSort("Improve InsertionSort", improveInsertionSort, arr, n);
// bubbleSort(arr, n);
// SortTestHelper::printArray(arr, n);
// SortTestHelper::testSort("Bubble Sort", bubbleSort, arr, n);
// mergeSort(arr, n);
// SortTestHelper::printArray(arr, n);
// SortTestHelper::testSort("Merge Sort", mergeSort, arr, n);
// mergeSortBottomToTop(arr, n);
// SortTestHelper::printArray(arr, n);
// SortTestHelper::testSort("Merge Sort Bottom To Top", mergeSortBottomToTop, arr, n);
// quickSort(arr, n);
// SortTestHelper::printArray(arr, n);
// SortTestHelper::testSort("Quick Sort", quickSort, arr, n);
// quickSortOptimize(arr, n);
// SortTestHelper::printArray(arr, n);
// SortTestHelper::testSort("Quick Sort Optimize", quickSortOptimize, arr, n);
// quickSortOptimize2(arr, n);
// SortTestHelper::printArray(arr, n);
// SortTestHelper::testSort("Quick Sort Optimize 2", quickSortOptimize2, arr, n);
// quickSortOptimize3(arr, n);
// SortTestHelper::printArray(arr, n);
// SortTestHelper::testSort("Quick Sort Optimize 3", quickSortOptimize3, arr, n);
// test for insert
/*
{
MaxHeap<int> maxheap = MaxHeap<int>(100);
cout<<maxheap.size()<<endl;
srand(time(NULL));
for (int i = 0; i < 15; i++)
{
maxheap.insert(rand()%100);
}
delete[] arr;
}
*/
// test for shifft down
/*
{
MaxHeap<int> maxheap = MaxHeap<int>(100);
cout<<maxheap.size()<<endl;
srand(time(NULL));
for (int i = 0; i < 15; i++)
{
maxheap.insert(rand()%100);
}
while (!maxheap.isEmpty())
{
printf("%d ", maxheap.extractMax());
}
delete[] arr;
}
*/
// SortTestHelper::testSort("Heap Sort heapSort1", heapSort1, arr, n);
// SortTestHelper::testSort("Heap Sort heapSort_heapify", heapSort_heapify, arr, n);
SortTestHelper::testSort("Heap Sort heapSort_InPlace", heapSort_InPlace, arr, n);
return 0;
}