Radix Sort Algorithm

Sections

1. What is Radix Sort?
2. Pseudo code of Radix Sort algorithm
3. Image Representation of Radix Sort


What is Radix Sort?

Radix sort is a sorting algorithm that takes an array of values and sorts them by comparing individual digits of the same place value. The algorithm then takes these elements and sorts them by increasing or decreasing value depending on what the user desries



Pseudo Code for Radix Sort

radixSort(int[] array, int numSize)
   //Every element in the array is a number with numSize digits
  //Digits numbered 1 to numSize from right to left
for (int j = 1; j < numSize; j++){ int count[10] = {0};}    //Store number of "keys" in count[]    //Key is number at digit place j for (int i = 0; i < array.size - 1; i++){ count[array[i]]++}

for (int k = 1; k < 10; k++){ count[k] = count[k] + count[k-1];}

//Build new array by checking new position of arr[i] from count[k]
for (int i = array.size - 1; i > -1; i--){
result[i] = array[j];
count[i]--;

//Now array contains sorted numbers according to digit place
for (int i = 0; i < array.size - 1; i++){
array[i] = result[i];}



Radix Image Representation

Link to other site describing Radix Sort

Link: https://www.programiz.com/dsa/radix-sort