LOGBOOK

HELP

Quiz Entry - updated: 2026.11.27

Radix-sort the tuples $(0,3,0)\;(1,2,1)\;(1,0,3)\;(0,1,2)$, components in $[0, 3]$: what do the four buckets hold at the end of each distribution phase?

  • Pass on dimension 3: $B[0] = (0,3,0)$, $B[1] = (1,2,1)$, $B[2] = (0,1,2)$, $B[3] = (1,0,3)$.
  • Pass on dimension 2: $B[0] = (1,0,3)$, $B[1] = (0,1,2)$, $B[2] = (1,2,1)$, $B[3] = (0,3,0)$.
  • Pass on dimension 1: $B[0] = (0,1,2)\,(0,3,0)$, $B[1] = (1,0,3)\,(1,2,1)$, $B[2]$ and $B[3]$ stay empty.

The four buckets after each of the three passes, with the digit used in each pass highlighted

* Each pass is a bucket-sort with four buckets on one component, starting with the last. *

After every pass the buckets are collected from $B[0]$ to $B[3]$, and that sequence is the input of the next pass:

  1. Dimension 3. The third components are 0, 1, 3, 2, so each tuple gets a bucket of its own. Collecting gives $(0,3,0)\;(1,2,1)\;(0,1,2)\;(1,0,3)$.
  2. Dimension 2. In this sequence the second components are 3, 2, 1, 0, so the order reverses: $(1,0,3)\;(0,1,2)\;(1,2,1)\;(0,3,0)$.
  3. Dimension 1. Two buckets receive two tuples each. Here stability shows: $(0,1,2)$ enters $B[0]$ before $(0,3,0)$ because pass 2 put it first, and pass 2 put it first because $1 < 3$ in dimension 2.

Collecting the last pass gives $(0,1,2)\;(0,3,0)\;(1,0,3)\;(1,2,1)$, the lexicographic order. Three passes over four buckets each: about $3(4 + 4)$ steps.

Go deeper:

From Quiz: ADS / Sorting Lower Bound, Bucket-Sort and Radix-Sort | Updated: Nov 27, 2026