-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
65 lines (51 loc) · 1.2 KB
/
main.cpp
File metadata and controls
65 lines (51 loc) · 1.2 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
#include <iostream>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/glext.h>
#include <GLUT/glut.h>
#include <stdlib.h>
#include <time.h>
#include "graph.h"
using namespace std;
// generate random array of size n
int getRandomArray(int arr[], int n, int range){
for(int i=0;i<n;i++) arr[i] = rand() % range;
return 0;
}
// driver code
int main(){
srand (time(NULL));
// size of array
int n=200;
int arr[n];
// range of numbers from 0 to n-1
int range = 460;
// time inverval for each operation in miliseconds
float time = 5;
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
Graph graph;
// Selection Sort
getRandomArray(arr, n, range);
graph.selectionSort(arr, n, time);
cleardevice();
// Insertion Sort
getRandomArray(arr, n, range);
graph.insertionSort(arr, n, time);
cleardevice();
// Quick Sort
getRandomArray(arr, n, range);
graph.quickSort(arr, 0, n-1, time);
cleardevice();
// Merge Sort
getRandomArray(arr, n, range);
graph.mergeSort(arr, 0, n-1, time);
cleardevice();
// Heap Sort
getRandomArray(arr, n, range);
graph.heapSort(arr, n, time);
// for(int i=0;i<n;i++) cout<<arr[i]<<" ";
getchar();
closegraph();
return 0;
}