Skip to content

Commit 5d1ff06

Browse files
committed
fixed some issues with radix
1 parent 4b75080 commit 5d1ff06

9 files changed

+7
-5
lines changed

bubble-sort.o

1.84 KB
Binary file not shown.

insertion-sort.o

3.29 KB
Binary file not shown.

option.o

10.7 KB
Binary file not shown.

radix-sort.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include "sort.h"
1010
#include <iostream>
11+
#include <cmath>
12+
using namespace std;
1113

1214
void
1315
RadixSort::sort(int A[], int size)
@@ -19,16 +21,16 @@ for(int i =0; i<size; ++i)//Find largest number
1921
if(A[i]>digits)
2022
digits=A[i];
2123
}
22-
digits=log10(digits);//find highest digit number
24+
digits=log(digits);//find highest digit number
2325
int B[10];
2426
int C[size];
2527
int D[size];
26-
pow=1;
28+
int power=1;
2729
while(true)//Get all the digits in the array
2830
{
2931
for(int j=0; j<size; ++j)//Set digits
3032
{
31-
D[j]=(A[j]/(pow))%10;
33+
D[j]=(A[j]/(power))%10;
3234
}
3335

3436
//Counting sort starts here
@@ -49,9 +51,9 @@ while(true)//Get all the digits in the array
4951
{
5052
A[n]=C[n];
5153
}
52-
if(digits=pow/10)//Detects if done with digits
54+
if(digits=power/10)//Detects if done with digits
5355
break;
54-
pow*=10;
56+
power*=10;
5557
}
5658

5759
}

radix-sort.o

5.43 KB
Binary file not shown.

selection-sort.o

4.34 KB
Binary file not shown.

shell-sort.o

4.75 KB
Binary file not shown.

sort

40.6 KB
Binary file not shown.

sort.o

19 KB
Binary file not shown.

0 commit comments

Comments
 (0)