#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::TAOCP Vol 3::5.2.5 Sorting by Distribution
#columns:Front	Back	Tags
TAOCP §5.2.5 Sorting by Distribution: what does it cover?	Radix sorting: distributing records into piles by digit, least significant digit first, using linked lists to avoid moving data, with analysis of when it beats comparison sorts.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.2.5 cracked.guide::kind::about
TAOCP §5.2.5: why does it matter?	Radix sort is how you sort integers, strings and fixed-size keys fast. It shows up in GPU sorting and database engines.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.2.5 cracked.guide::kind::why
TAOCP §5.2.5: what traps should you watch for?	<ul><li>Non-stable distribution passes break LSD radix sort.</li></ul>	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.2.5 cracked.guide::kind::traps
TAOCP §5.2.5, exercise 2 (rated 13): what is it asking?	Is radix sort stable? It has to be, and the reason is the whole trick.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.2.5 cracked.guide::kind::exercise
TAOCP §5.2.5, exercise 1 (rated 20, recommended): what is it asking?	Would in-place distribution counting beat the linked radix sort? Compare the costs.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.2.5 cracked.guide::kind::exercise
TAOCP §5.2.5, exercise 8 (rated 20, recommended): what is it asking?	Adapt radix sorting to two's complement and ones' complement keys.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.2.5 cracked.guide::kind::exercise
TAOCP §5.2.5, exercise 14 (rated 22): what is it asking?	A card-dealing puzzle: sort a hand with two piles in two passes. Radix sort in disguise.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.2.5 cracked.guide::kind::exercise
TAOCP §5.2.5, exercise 4 (rated 23, recommended): what is it asking?	Link the piles as stacks instead of queues and find an order that still sorts.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.2.5 cracked.guide::kind::exercise
TAOCP §5.2.5, exercise 16 (rated 25, recommended): what is it asking?	Sort strings of mixed lengths in time linear in their total length. The basis of practical string sorting.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.2.5 cracked.guide::kind::exercise
TAOCP §5.2.5, exercise 6 (rated M24): what is it asking?	Expected number of empty piles after one distribution pass. The math stretch.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.2.5 cracked.guide::kind::exercise
TAOCP §5.2.5: how many exercises, and how are they rated?	18 exercises, rated 13 to 40.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.2.5 cracked.guide::kind::exercises
TAOCP §5.2.5: what should you be comfortable with first?	<ul><li>5.2.4 Sorting by Merging</li></ul>	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.2.5 cracked.guide::kind::prereqs
TAOCP §5.2.5: how should you work through it?	Implement LSD radix sort on 32-bit integers with byte-sized digits and counting sort per pass. Benchmark it against your quicksort.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.2.5 cracked.guide::kind::approach
