#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::TAOCP Vol 3::5.3.4 Networks for Sorting
#columns:Front	Back	Tags
TAOCP §5.3.4 Networks for Sorting: what does it cover?	Sorting networks: fixed sequences of compare-exchange operations that do not depend on the data. Knuth covers the zero-one principle, Batcher's networks, optimal small networks, and related merging and selection networks.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.3.4 cracked.guide::kind::about
TAOCP §5.3.4: why does it matter?	Sorting networks are used in GPUs, SIMD code and hardware because they are branch-free and parallel. The zero-one principle is a great proof trick.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.3.4 cracked.guide::kind::why
TAOCP §5.3.4, a common trap: “Verifying a network on random inputs only.” What's the catch?	Use the zero-one principle to test exhaustively.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.3.4 cracked.guide::kind::trap
TAOCP §5.3.4, exercise 1 (rated 20): what is it asking?	Draw Batcher's odd-even merge network for 3 and 5 inputs.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.3.4 cracked.guide::kind::exercise
TAOCP §5.3.4, exercise 15 (rated 20): what is it asking?	Find a nonstandard four-element sorting network with five comparators.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.3.4 cracked.guide::kind::exercise
TAOCP §5.3.4, exercise 28 (rated M20, recommended): what is it asking?	Write down what each line of a network computes as a formula of mins and maxes.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.3.4 cracked.guide::kind::exercise
TAOCP §5.3.4, exercise 36 (rated 22, recommended): what is it asking?	Networks that compare only neighbors need about n^2/2 comparators. Bubble sort as a network.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.3.4 cracked.guide::kind::exercise
TAOCP §5.3.4, exercise 4 (rated M23, recommended): what is it asking?	Prove the minimum delay for sorting six elements.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.3.4 cracked.guide::kind::exercise
TAOCP §5.3.4, exercise 13 (rated 24, recommended): what is it asking?	Build a sorting network from perfect shuffles. The pattern behind several parallel machines.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.3.4 cracked.guide::kind::exercise
TAOCP §5.3.4, exercise 42 (rated 25, recommended): what is it asking?	A lower bound on comparators that grows by about lg n per added element.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.3.4 cracked.guide::kind::exercise
TAOCP §5.3.4, exercise 14 (rated M27, recommended): what is it asking?	Alekseev's transformation of networks and what it preserves. The stretch.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.3.4 cracked.guide::kind::exercise
TAOCP §5.3.4: how many exercises, and how are they rated?	68 exercises, rated M16 to 50.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.3.4 cracked.guide::kind::exercises
TAOCP §5.3.4: what should you be comfortable with first?	<ul><li>5.3.1 Minimum-Comparison Sorting</li></ul>	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.3.4 cracked.guide::kind::prereqs
TAOCP §5.3.4: how should you work through it?	Draw a few networks for 4 and 5 elements. Write a program that verifies a network by testing all 0-1 inputs. Implement Batcher's bitonic or odd-even merge network.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::5.3.4 cracked.guide::kind::approach
