35.3 MSD Radix Sort
Basic idea: Just like LSD, but sort from leftmost digit towards the right.
Last updated
Basic idea: Just like LSD, but sort from leftmost digit towards the right.
Last updated
Notice first we sorted by leftmost digit. Then we grouped the data by the leftmost digit, so one group would start with a's, then the next group would start with b's, and so on and so forth. Then within our subgroups we would order by middle digit, and create newer subgroups. And finally we would break this up into further subgroups until we have all individual subproblems. This final result would be sorted.
Best Case.
Worst Case.
We finish in one counting sort pass, looking only at the top digit:
We have to look at every character, degenerating to LSD sort: