#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::TAOCP Vol 3::6.2.1 Searching an Ordered Table
#columns:Front	Back	Tags
TAOCP §6.2.1 Searching an Ordered Table: what does it cover?	Binary search and its variants: uniform binary search, Fibonacci search, and interpolation search, with analysis and a careful look at how easy it is to get binary search wrong.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::6.2.1 cracked.guide::kind::about
TAOCP §6.2.1: why does it matter?	Binary search is famously hard to write correctly. Knowing the variants also helps with things like branch-free search and searching on sorted disk pages.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::6.2.1 cracked.guide::kind::why
TAOCP §6.2.1: what traps should you watch for?	<ul><li>Off-by-one in bounds and infinite loops when lo and hi are adjacent.</li><li>Midpoint overflow on very large arrays.</li></ul>	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::6.2.1 cracked.guide::kind::traps
TAOCP §6.2.1, exercise 3 (rated 15): what is it asking?	Identify the search method behind a given tree and compute its average costs.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::6.2.1 cracked.guide::kind::exercise
TAOCP §6.2.1, exercise 1 (rated 21, recommended): what is it asking?	Prove what the bounds mean when binary search fails. This is the loop invariant.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::6.2.1 cracked.guide::kind::exercise
TAOCP §6.2.1, exercise 2 (rated 22, recommended): what is it asking?	Do two tempting shortcuts in the bound updates still work?	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::6.2.1 cracked.guide::kind::exercise
TAOCP §6.2.1, exercise 24 (rated 23, recommended): what is it asking?	Binary search on the heap-ordered layout, using doubling instead of halving. Cache-friendly search.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::6.2.1 cracked.guide::kind::exercise
TAOCP §6.2.1, exercise 29 (rated 22, recommended): what is it asking?	Search keys that are only sorted up to a fixed involution.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::6.2.1 cracked.guide::kind::exercise
TAOCP §6.2.1, exercise 7 (rated M22, recommended): what is it asking?	Do small changes to the start of uniform binary search break it?	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::6.2.1 cracked.guide::kind::exercise
TAOCP §6.2.1, exercise 23 (rated 25, recommended): what is it asking?	Bottenbruch's variant that tests for equality only at the end. The form most libraries use.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::6.2.1 cracked.guide::kind::exercise
TAOCP §6.2.1, exercise 25 (rated M25, recommended): what is it asking?	Relate internal and external node counts per level by generating functions. The math stretch.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::6.2.1 cracked.guide::kind::exercise
TAOCP §6.2.1: how many exercises, and how are they rated?	30 exercises, rated 15 to M42.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::6.2.1 cracked.guide::kind::exercises
TAOCP §6.2.1: what should you be comfortable with first?	<ul><li>6.1 Sequential Searching</li></ul>	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::6.2.1 cracked.guide::kind::prereqs
TAOCP §6.2.1: how should you work through it?	Write binary search from memory, then test it exhaustively on all arrays up to size 10 and all targets. Implement interpolation search and test it on uniform and skewed data.	cracked.guide cracked.guide::phase::taocp-3 cracked.guide::section::6.2.1 cracked.guide::kind::approach
