Mental Model
Counting sort counts how many times each number appears, then uses these counts to place numbers in order without comparing them.
Analogy: Imagine sorting colored balls by counting how many balls of each color you have, then lining them up color by color based on those counts.
Input array: 4 -> 2 -> 2 -> 8 -> 3 -> 3 -> 1 -> null Count array: [0,0,0,0,0,0,0,0,0] Output array: [ , , , , , , , ]