#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::TAOCP Vol 1::2.3.1 Traversing Binary Trees
#columns:Front	Back	Tags
TAOCP §2.3.1 Traversing Binary Trees: what does it cover?	Binary trees, the three traversal orders (preorder, inorder, postorder), traversal with an explicit stack instead of recursion, and threaded trees where spare null links point to inorder successors.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.1 cracked.guide::kind::about
TAOCP §2.3.1: why does it matter?	Tree traversal is everywhere: ASTs in your interpreters, DOM trees, file systems. Converting recursion to an explicit stack is a practical skill when recursion depth is a risk.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.1 cracked.guide::kind::why
TAOCP §2.3.1, a common trap: “Threads and real links look identical without the tag bit.” What's the catch?	Keep the tag.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.1 cracked.guide::kind::trap
TAOCP §2.3.1: what traps should you watch for?	<ul><li>Confusing the order in which you push left and right children.</li></ul>	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.1 cracked.guide::kind::traps
TAOCP §2.3.1, exercise 21 of §2.3 (rated M22): what is it asking?	From the 2.3 opener: count leaves from the numbers of nodes of each degree.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.1 cracked.guide::kind::exercise
TAOCP §2.3.1, exercise 2 (rated 11): what is it asking?	List a small tree's nodes in all three orders.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.1 cracked.guide::kind::exercise
TAOCP §2.3.1, exercise 4 (rated 20, recommended): what is it asking?	Look at a mirror-image traversal order and relate it to the standard ones.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.1 cracked.guide::kind::exercise
TAOCP §2.3.1, exercise 7 (rated 22): what is it asking?	Rebuild a binary tree from its preorder and inorder. The interview favorite, from the source.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.1 cracked.guide::kind::exercise
TAOCP §2.3.1, exercise 13 (rated 24): what is it asking?	Write a stack-based postorder traversal. The tricky one.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.1 cracked.guide::kind::exercise
TAOCP §2.3.1, exercise 17 (rated 22, recommended): what is it asking?	Find the preorder successor in a threaded tree.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.1 cracked.guide::kind::exercise
TAOCP §2.3.1, exercise 30 (rated 22, recommended): what is it asking?	Thread an unthreaded tree.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.1 cracked.guide::kind::exercise
TAOCP §2.3.1, exercise 21 (rated 33, recommended): what is it asking?	Traverse in inorder with no stack by temporarily rewiring links. The stretch.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.1 cracked.guide::kind::exercise
TAOCP §2.3.1: how many exercises, and how are they rated?	37 exercises, rated 00 to HM41.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.1 cracked.guide::kind::exercises
TAOCP §2.3.1: what should you be comfortable with first?	<ul><li>2.2.3 Linked Allocation</li><li>Recursion</li></ul>	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.1 cracked.guide::kind::prereqs
TAOCP §2.3.1: how should you work through it?	Read the opening pages of 2.3 (Trees) first: the definitions, the drawing conventions, Dewey notation, forests and Lists. The curriculum has no separate week for them and 2.3.1 assumes them. Then implement inorder traversal with an explicit stack and confirm it matches the recursive version on random trees. Build a threaded tree and walk it without any stack. Compare to the AST visitors from jlox.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.1 cracked.guide::kind::approach
