Bölüm 5 · Simülatör

String Sorting: LSD Radix Sort

← Bölüm 5

Current Array

Buckets

Ready.

String Sorting: LSD Radix Sort

Sort strings stably from the rightmost character to the leftmost character using buckets.

How to use

  • Enter comma-separated strings (up to 12 strings of at most 10 characters) and press Load Data.
  • Step Forward performs one pass: every string goes into the bucket of its character at the current position, then the buckets are concatenated in character order. Auto Run performs the remaining passes; Reset reloads the input.
  • The highlighted column is the position used in the last pass; green columns have already been processed.

Different lengths

If strings have different lengths, shorter strings are internally right-padded with blank characters (shown as ·) so that every position can be processed. The blank sorts before every other character, so a string comes before its own extensions (for example "be" before "bed"), which is the lexicographic order.

Why it works

Each pass is a stable distribution: strings with equal characters at the current position keep the order produced by the earlier passes. After the pass on position 0, the strings are sorted by all positions.

Complexity

MeasureValue
TimeO(W · (n + R)) for n strings of width W and alphabet size R
Extra spaceO(n + R)
StableYes