Skip to content

Commit 05bd7a9

Browse files
Radix Sort
1 parent 9874e1c commit 05bd7a9

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

radix.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <stdio.h>
2+
#include <stdint.h>
3+
#include <time.h>
4+
5+
#include "generic.h"
6+
#include "radix_sort.h"
7+
8+
int main()
9+
{
10+
using namespace alg;
11+
const int MAX_ELEMENTS = 10;
12+
uint32_t list[MAX_ELEMENTS];
13+
14+
int i = 0;
15+
srand(time(NULL));
16+
// generate random numbers and fill them to the list
17+
for(i = 0; i < MAX_ELEMENTS; i++ ){
18+
list[i] = rand()%100;
19+
}
20+
21+
printf("The list before sorting is:\n");
22+
printlist(list,MAX_ELEMENTS);
23+
24+
// sort the list using insertion sort
25+
radix_sort(list, MAX_ELEMENTS);
26+
check_order(list, MAX_ELEMENTS);
27+
28+
// print the result
29+
printf("The list after sorting using radix sort algorithm:\n");
30+
printlist(list,MAX_ELEMENTS);
31+
32+
return 0;
33+
}

0 commit comments

Comments
 (0)