forked from iam-abbas/cs-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathradix.cpp
More file actions
33 lines (26 loc) · 684 Bytes
/
Copy pathradix.cpp
File metadata and controls
33 lines (26 loc) · 684 Bytes
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
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include "generic.h"
#include "radix_sort.h"
int main()
{
using namespace alg;
const int MAX_ELEMENTS = 10;
uint32_t list[MAX_ELEMENTS];
int i = 0;
srand(time(NULL));
// generate random numbers and fill them to the list
for(i = 0; i < MAX_ELEMENTS; i++ ){
list[i] = rand()%100;
}
printf("The list before sorting is:\n");
printlist(list,MAX_ELEMENTS);
// sort the list using insertion sort
radix_sort(list, MAX_ELEMENTS);
check_order(list, MAX_ELEMENTS);
// print the result
printf("The list after sorting using radix sort algorithm:\n");
printlist(list,MAX_ELEMENTS);
return 0;
}