-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.c
More file actions
110 lines (84 loc) · 1.92 KB
/
test.c
File metadata and controls
110 lines (84 loc) · 1.92 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
#include <stdio.h>
#include <stdlib.h>
/**
*
* Driver programs to test all sort functions
*
* TestQuickSort()
* TestBubbleSort()
* TestTriSelection()
* TestMergeSort()
*
**/
/**
*
* Driver program to test QuickSort functions
*
**/
void TestQuickSort()
{
int arr[] = { 100, 500, 50, 12, 7, 11, 6, 13, 5 ,3 };
int arr_size = sizeof(arr) / sizeof(arr[0]);
printf("Given array is \n");
printArray(arr, arr_size);
quickSort(arr, 0, arr_size - 1);
printf("\nSorted array is \n");
printArray(arr, arr_size);
}
/**
*
* Driver program to test BubbleSort functions
*
**/
void TestBubbleSort()
{
int arr[] = { 100, 500, 50, 12, 7, 11, 6, 13, 5 ,3 };
int arr_size = sizeof(arr) / sizeof(arr[0]);
printf("Given array is \n");
printArray(arr, arr_size);
bubbleSort(arr, arr_size);
printf("\nSorted array is \n");
printArray(arr, arr_size);
}
/**
*
* Driver program to test TriSelection functions
*
**/
void TestTriSelection()
{
int arr[] = { 100, 500, 50, 12, 7, 11, 6, 13, 5 ,3 };
int arr_size = sizeof(arr) / sizeof(arr[0]);
printf("Given array is \n");
printArray(arr, arr_size);
TriSelection(arr, arr_size);
printf("\nSorted array is \n");
printArray(arr, arr_size);
}
/**
*
* Driver program to test MergeSort functions
*
**/
void TestMergeSort()
{
int array[] = { 100, 500, 50, 12, 7, 11, 6, 13, 5 ,3 };
int arr_size = sizeof(array) / sizeof(array[0]);
printf("Given array is \n");
printArray(array, arr_size);
mergeSort(array, 0, arr_size - 1);
printf("\nSorted array is \n");
printArray(array, arr_size);
}
/** Drivers to test every sort functions **/
void TestSortFunctions()
{
printf("TestQuickSort\n\n");
TestQuickSort();
printf("\n\n\nTestBubbleSort\n\n");
TestBubbleSort();
printf("\n\n\nTestTriSelection\n\n");
TestTriSelection();
printf("\n\n\nTestMergeSort\n\n");
TestMergeSort();
}