-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.cpp
More file actions
45 lines (38 loc) · 1.17 KB
/
debug.cpp
File metadata and controls
45 lines (38 loc) · 1.17 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
// C++ program to demonstrate performance of sorting algorithms
#include <bits/stdc++.h>
using namespace std;
// Importing functions from another local
#include "bubble-Sort.h"
#include "selection-Sort.h"
#include "insertion-Sort.h"
#include "binary_insertion-Sort.h"
#include "merge-Sort.h"
// Number of elements to be sorted
//you can define how much elements your computer handle
#define N 1000000
// Driver program to test above functions
int main()
{
// long long int biArr[N], stArr[N], arr[N], iArr[N], sArr[N], bArr[N];
long long int arr[N];
// seed for random input
srand(time(NULL));
// to measure time taken by qsort and sort
clock_t begin, end;
double time_spent;
// generate random input
// we repeat this loop on every different method, i dont find a better solutions :3
// calculate time taken by selectionSort function
for (int i = 0; i < N; i++)
{
arr[i] = rand() % 400000;
}
time_spent = 0.0;
begin = clock();
selectionSort(arr, N);
end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
cout << "Time taken by selectionSort() - "
<< time_spent << endl;
return 0;
}