35.2 LSD Radix Sort

Notice in the above picture that we had a completely random input of numbers 22, 34, 41, etc. Then in the second box, we had sorted by right most digit, so 41, 41, 31 would come first as 1 is the lowest rightmost digit. Next would come 32, 22, 12, as 2 is the second least rightmost digit. Notice that we still have to take care of sorting 32, 22, and 12 which is why we move to the second right most digit in our last box which has everything sorted.

What is the runtime of LSD sort?

  • Θ(WN+WR)\Theta(WN+WR)

  • NN: Number of items, RR: size of alphabet, WW: Width of each item in # digits

Last updated