DSAVisualiseData Structures & Algorithms Studio
Sorting & Selection Easy

LSD Radix Sort

This source uses a least-significant-bit-first radix sort. Each bit pass is a stable two-bucket counting sort, so low-order decisions accumulate into the final order.

Trace input

Bounded JSON

Edit the lesson input, then build a deterministic source-linked trace.

This lesson validates its own input and operation limits.

Source scenarios

Complexity

BestO(N · W)
AverageO(N · W)
WorstO(N · W)
SpaceO(N)

Array state

Follow the active comparisons and writes.

Live snapshot

Current operation

Trace state
Ready to explore
Source behavior & common mistakes

Follow max-bit detection, count each bit, convert counts to destination boundaries, fill the auxiliary array from right to left, and copy each pass back. Compare the source's nonnegative baseline with the signed inputs its current code does not fully support.

  • This is binary LSD radix sort: it performs one stable counting pass per significant bit, not one pass per decimal digit.
  • The right-to-left placement loop is what preserves order among items with the same current bit.
  • The pinned source assumes nonnegative integers. It initializes max to zero and never processes the sign bit, so negative-only arrays are left unchanged and mixed signed input is not guaranteed to sort numerically.
  • The implementation uses Java int values. Its supported nonnegative range is 0 through Integer.MAX_VALUE; the largest value needs 31 passes.
  • Duplicate values remain distinct in the visualization by input identity; the source moves their values stably through each pass.

Algorithm code

Java
RadixSort.javaStep linked
The highlighted line follows the current step.

Ready to begin

Press Play to see what happens.

Detailed execution
Snapshot 1 / 1
Writes 0