logo
SEE ALGORITHMS
    Bubble Sort
    Insertion Sort
    Selection Sort
    Heap Sort
    Radix Sort
    Merge Sort
    Quick Sort

Radix Sort

Radix Sort organizes numbers by sorting them digit by digit. It starts with the least significant digit (rightmost) and works to the most significant digit (leftmost). Numbers are placed into buckets based on each digit's value, then collected back together in order. This process is repeated for each digit, leading to arr sorted list.

Things to Observe

  • Digit by Digit: Notice how the sorting happens in passes, one for each digit place (ones, tens, hundreds, etc.), starting from the rightmost digit.
  • Bucketing: In each pass, watch how the numbers are distributed into "buckets" (0-9) based on the value of the current digit. They are then collected back from the buckets in order, preserving the relative order from the previous pass.

Pseudocode

max = largest(arr)
exp = 1
while (max / exp) > 0:
    buckets[0..9] = empty stacks
    for i = 0 to (n - 1):
        d = (arr[i] / exp) % 10
        push arr[i] to buckets[d]
    k = n - 1
    for j = 9 to 0:
        b = buckets[j]
        while b is not empty:
            arr[k] = b.pop()
            k = k - 1
    exp = exp * 10
Select number of elements:  

Curious to Learn More?

Hand-picked resources to deepen your understanding

Beginner Friendly
Coding Interview Bootcamp: Algorithms + Data Structures

Learn essential data structures and algorithms step-by-step with practical JavaScript examples.

Practical Guide
JavaScript Algorithms & Data Structures Masterclass

Master DSA fundamentals, problem-solving techniques, and advanced structures using JavaScript.

Deep Dive
Master the Coding Interview: Data Structures + Algorithms

Prepare for top tech interviews with advanced DSA concepts and real-world coding challenges.

As an Udemy Associate, I earn from qualifying purchases. This helps support the site at no extra cost to you.

© 2025 SEE Algorithms. Code licensed under MIT, content under CC BY-NC 4.0.