|
| 1 | +Radix Sort The lower bound for Comparison based sorting algorithm (Merge Sort, Heap Sort, Quick-Sort .. etc) is Ω(nLogn), i.e., they cannot do better than nLogn. |
| 2 | + |
| 3 | +Counting sort is a linear time sorting algorithm that sort in O(n+k) time when elements are in range from 1 to k. |
| 4 | + |
| 5 | +What if the elements are in range from 1 to n2? |
| 6 | + |
| 7 | +We can’t use counting sort because counting sort will take O(n2) which is worse than comparison based sorting algorithms. Can we sort such an array in linear time? Radix Sort is the answer. The idea of Radix Sort is to do digit by digit sort starting from least significant digit to most significant digit. Radix sort uses counting sort as a subroutine to sort. |
| 8 | + |
| 9 | +The Radix Sort Algorithm |
| 10 | + |
| 11 | +Do following for each digit i where i varies from least significant digit to the most significant digit. a) Sort input array using counting sort (or any stable sort) according to the i’th digit. |
0 commit comments