From 2ed6bc98314300083102ed6e94ada68205da76c5 Mon Sep 17 00:00:00 2001 From: Himanshu Patel <44549418+Himanshu27299@users.noreply.github.com> Date: Sat, 11 May 2019 21:44:41 +0530 Subject: [PATCH] Minor grammatical corrections. (#31228) --- .../sorting-algorithms/radix-sort/index.md | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/guide/english/algorithms/sorting-algorithms/radix-sort/index.md b/guide/english/algorithms/sorting-algorithms/radix-sort/index.md index 9fd1a76c2a..ad40592a42 100644 --- a/guide/english/algorithms/sorting-algorithms/radix-sort/index.md +++ b/guide/english/algorithms/sorting-algorithms/radix-sort/index.md @@ -20,7 +20,7 @@ We used count sort because it is a stable sort. Example: Assume the input array is: -10,21,17,34,44,11,654,123 +10, 21, 17, 34, 44, 11, 654, 123 Based on the algorithm, we will sort the input array according to the one's digit (least significant digit). @@ -35,7 +35,7 @@ Based on the algorithm, we will sort the input array according to the one's digi 8:
9:
-So, the array becomes 10,21,11,123,24,44,654,17 +So, the array becomes 10, 21, 11, 123, 24, 44, 654, 17 Now, we'll sort according to the ten's digit: 0:
@@ -49,7 +49,7 @@ Now, we'll sort according to the ten's digit: 8:
9: -Now, the array becomes : 10,11,17,21,123,34,44,654 +Now, the array becomes : 10, 11, 17, 21, 123, 34, 44, 654 Finally , we sort according to the hundred's digit (most significant digit): 0: 010 011 017 021 034 044
@@ -63,52 +63,38 @@ Finally , we sort according to the hundred's digit (most significant digit): 8:
9: -The array becomes : 10,11,17,21,34,44,123,654 which is sorted. This is how our algorithm works. +The array becomes : 10, 11, 17, 21, 34, 44, 123, 654 which is sorted. This is how our algorithm works. An implementation in C: ``` void countsort(int arr[],int n,int place){ int i,freq[range]={0}; //range for integers is 10 as digits range from 0-9 - int output[n]; for(i=0;i=0;i--){ - output[freq[(arr[i]/place)%range]-1]=arr[i]; - freq[(arr[i]/place)%range]--; - } - + for(i=0;i