#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::TAOCP Vol 1::1.2.10 Analysis of an Algorithm
#columns:Front	Back	Tags
TAOCP §1.2.10 Analysis of an Algorithm: what does it cover?	A complete worked analysis of a simple algorithm (finding the maximum of n elements): best case, worst case, average, and full probability distribution of how often the running maximum changes. It is the template for every analysis in the series.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.2.10 cracked.guide::kind::about
TAOCP §1.2.10: why does it matter?	This is the method behind every &quot;average case O(n log n)&quot; claim. Seeing it done end to end on a small example teaches you what those claims actually mean.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.2.10 cracked.guide::kind::why
TAOCP §1.2.10, fill in the blank:<br>This is the method behind every &quot;average case <span class="cg-blank">&nbsp;</span>&quot; claim.	This is the method behind every &quot;average case <b>O(n log n)</b>&quot; claim.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.2.10 cracked.guide::kind::complexity
TAOCP §1.2.10, a common trap: “Skipping the variance.” What's the catch?	The mean alone hides how spread out the cost is.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.2.10 cracked.guide::kind::trap
TAOCP §1.2.10, a common trap: “Confusing the number of comparisons with the number of updates.” What's the catch?	Knuth counts specific steps.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.2.10 cracked.guide::kind::trap
TAOCP §1.2.10, exercise 1 (rated 10): what is it asking?	Interpret a boundary probability in terms of the max-finding algorithm.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.2.10 cracked.guide::kind::exercise
TAOCP §1.2.10, exercise 3 (rated M15): what is it asking?	Min, max, mean and standard deviation of the update count for a concrete n.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.2.10 cracked.guide::kind::exercise
TAOCP §1.2.10, exercise 5 (rated M13): what is it asking?	Read the mean and standard deviation off a pictured distribution.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.2.10 cracked.guide::kind::exercise
TAOCP §1.2.10, exercise 8 (rated M20, recommended): what is it asking?	Redo part of the analysis when values are drawn with repetition from a finite set.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.2.10 cracked.guide::kind::exercise
TAOCP §1.2.10, exercise 11 (rated M15, recommended): what is it asking?	See what shifting a distribution does to its cumulants.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.2.10 cracked.guide::kind::exercise
TAOCP §1.2.10, exercise 19 (rated M21): what is it asking?	Left-to-right maxima of a random permutation. The same quantity in another costume.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.2.10 cracked.guide::kind::exercise
TAOCP §1.2.10, exercise 20 (rated M22, recommended): what is it asking?	Use sortedness to cut the work of a max-of-differences computation. A real optimization.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.2.10 cracked.guide::kind::exercise
TAOCP §1.2.10, exercise 7 (rated M27, recommended): what is it asking?	Redo the analysis of the max algorithm without assuming distinct values. The stretch.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.2.10 cracked.guide::kind::exercise
TAOCP §1.2.10: how many exercises, and how are they rated?	23 exercises, rated 10 to HM38.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.2.10 cracked.guide::kind::exercises
TAOCP §1.2.10: what should you be comfortable with first?	<ul><li>1.2.7 Harmonic Numbers</li><li>1.2.9 Generating Functions</li><li>Basic probability: mean and variance</li></ul>	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.2.10 cracked.guide::kind::prereqs
TAOCP §1.2.10: how should you work through it?	Write the algorithm in a real language, instrument it to count how often the max changes, and run it over many random permutations. Compare your measured mean to Knuth's formula. Then go through the probability generating function derivation with pencil.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.2.10 cracked.guide::kind::approach
