#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::TAOCP Vol 3::5.4.1 Multiway Merging and Replacement Selection
#columns:Front	Back	Tags
TAOCP §5.4.1 Multiway Merging and Replacement Selection: what does it cover?	Merging many sorted runs at once using a tree of losers, and replacement selection, which produces initial sorted runs about twice the size of memory on random data (the snowplow argument).	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.4.1 cracked.guide::kind::about
TAOCP §5.4.1: why does it matter?	This is still exactly how external sorts and database sort operators work when data does not fit in RAM. Probably the most practical section of 5.4.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.4.1 cracked.guide::kind::why
TAOCP §5.4.1: what traps should you watch for?	<ul><li>Forgetting to mark records that belong to the next run in replacement selection.</li></ul>	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.4.1 cracked.guide::kind::traps
TAOCP §5.4.1, exercise 13 (rated 13): what is it asking?	Why is the second run from replacement selection usually longer than the first?	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.4.1 cracked.guide::kind::exercise
TAOCP §5.4.1, exercise 3 (rated 16): what is it asking?	Run four-way replacement selection by hand on a famous sentence.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.4.1 cracked.guide::kind::exercise
TAOCP §5.4.1, exercise 18 (rated 22, recommended): what is it asking?	What happens if you run replacement selection on its own output?	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.4.1 cracked.guide::kind::exercise
TAOCP §5.4.1, exercise 9 (rated 23, recommended): what is it asking?	Make replacement selection produce some runs ascending and others descending, as later tape methods need.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.4.1 cracked.guide::kind::exercise
TAOCP §5.4.1, exercise 19 (rated HM22): what is it asking?	Use the snowplow argument to show the first run is about (e - 1) times memory.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.4.1 cracked.guide::kind::exercise
TAOCP §5.4.1, exercise 14 (rated HM25, recommended): what is it asking?	Estimate the length of the last two runs using the snowplow picture.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.4.1 cracked.guide::kind::exercise
TAOCP §5.4.1, exercise 21 (rated HM23, recommended): what is it asking?	Run lengths for natural selection with a small reservoir.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.4.1 cracked.guide::kind::exercise
TAOCP §5.4.1, exercise 27 (rated HM30, recommended): what is it asking?	Analyze a refinement of natural selection that keeps filling the queue. The stretch.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.4.1 cracked.guide::kind::exercise
TAOCP §5.4.1: how many exercises, and how are they rated?	30 exercises, rated 00 to M46.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.4.1 cracked.guide::kind::exercises
TAOCP §5.4.1: what should you be comfortable with first?	<ul><li>5.2.3 Sorting by Selection (heaps)</li></ul>	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.4.1 cracked.guide::kind::prereqs
TAOCP §5.4.1: how should you work through it?	Implement replacement selection with a heap and measure run lengths on random data; you should see about 2P. Implement a k-way merge with a heap. Read the snowplow analogy carefully; it is a lovely argument.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.4.1 cracked.guide::kind::approach
