#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::TAOCP Vol 1::1.1 Algorithms
#columns:Front	Back	Tags
TAOCP §1.1 Algorithms: what does it cover?	Knuth opens with Euclid's algorithm for the greatest common divisor and uses it to pin down what an algorithm actually is: finite, definite, with input, output and effective steps. He also introduces his house style for writing algorithms as lettered, numbered steps, and sketches a formal model of computation at the end.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.1 cracked.guide::kind::about
TAOCP §1.1: why does it matter?	Every later section uses this step-by-step format, so getting comfortable with it now pays off for 100+ weeks. The five properties are also a decent checklist for any spec you write at work: if a step is not definite or not guaranteed to terminate, you have a bug waiting to happen.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.1 cracked.guide::kind::why
Euclid's algorithm: what is it?	Euclid's algorithm computes the greatest common divisor of two positive integers by repeatedly replacing the larger with its remainder modulo the smaller until the remainder is zero.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.1 cracked.guide::kind::definition
Euclid's algorithm: What is the extended Euclidean algorithm?	The same loop, also tracking coefficients so that it returns x and y with mx + ny = gcd(m, n). It is how you compute modular inverses.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.1 cracked.guide::kind::definition
TAOCP §1.1, a common trap: “Getting stuck on the formal definition at the end of the section.” What's the catch?	It is optional on a first read.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.1 cracked.guide::kind::trap
TAOCP §1.1, a common trap: “Treating the exercise ratings as difficulty for you personally.” What's the catch?	They are Knuth's estimate of time for a prepared reader; a 20 can take you an hour early on and that is normal.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.1 cracked.guide::kind::trap
TAOCP §1.1, a common trap: “Buying an old edition by accident.” What's the catch?	You want Vol 1, 3rd edition (1997, with later printings).	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.1 cracked.guide::kind::trap
TAOCP §1.1, exercise 1 (rated 10): what is it asking?	Rearrange four variables with as few replacement steps as possible. The same ordering problem that bites people in swap code.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.1 cracked.guide::kind::exercise
TAOCP §1.1, exercise 2 (rated 15): what is it asking?	Prove a fact about m and n at the top of the loop. First practice reasoning about an algorithm's state instead of just running it.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.1 cracked.guide::kind::exercise
TAOCP §1.1, exercise 3 (rated 20): what is it asking?	Rework Euclid's algorithm so it never does a pure copy step, written in Knuth's step format. Very doable and a good first rewrite.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.1 cracked.guide::kind::exercise
TAOCP §1.1, exercise 5 (rated 12, recommended): what is it asking?	Audit the reading procedure from the preface against the five properties of an algorithm. Fun, and it makes the definitions stick.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.1 cracked.guide::kind::exercise
TAOCP §1.1: how many exercises, and how are they rated?	9 exercises, rated 10 to M30.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.1 cracked.guide::kind::exercises
TAOCP §1.1: what should you be comfortable with first?	<ul><li>Comfort reading pseudocode</li><li>Remainders and division (week 0 math)</li></ul>	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.1 cracked.guide::kind::prereqs
TAOCP §1.1: how should you work through it?	Before the section itself, read Knuth's &quot;Notes on the Exercises&quot; at the front of the book (the preface's reading procedure sends you there too). It explains the rating scale (00 to 50 in steps of ten, M for mathematical, HM for higher math like calculus) and the triangle that marks recommended exercises, which you will rely on for the next two years. Then trace Algorithm E by hand on a few pairs of numbers until it feels boring. Read the five properties slowly. The last few pages on a set-theoretic definition of computation are fine to skim on a first pass; come back to them later if you are curious.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.1 cracked.guide::kind::approach
