#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::TAOCP Vol 1::2.3.5 Lists and Garbage Collection
#columns:Front	Back	Tags
TAOCP §2.3.5 Lists and Garbage Collection: what does it cover?	General lists that can share sublists and even contain themselves, reference counting, and garbage collection by marking reachable nodes. It includes the famous trick of marking without an auxiliary stack by temporarily reversing links (Schorr-Waite).	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.5 cracked.guide::kind::about
TAOCP §2.3.5: why does it matter?	You wrote a mark-sweep collector for clox in chapter 26 of Crafting Interpreters. This section shows the same problem with tight memory, and link reversal is a classic example of clever pointer manipulation.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.5 cracked.guide::kind::why
TAOCP §2.3.5, a common trap: “Reference counting cannot reclaim cycles.” What's the catch?	Knuth explains why; make sure you can too.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.5 cracked.guide::kind::trap
TAOCP §2.3.5: what traps should you watch for?	<ul><li>In link reversal, forgetting to restore a link on the way back up.</li></ul>	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.5 cracked.guide::kind::traps
TAOCP §2.3.5, exercise 1 (rated M21, recommended): what is it asking?	Describe List structures as directed graphs.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.5 cracked.guide::kind::exercise
TAOCP §2.3.5, exercise 6 (rated 00): what is it asking?	Where the cost term proportional to total memory comes from in garbage collection.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.5 cracked.guide::kind::exercise
TAOCP §2.3.5, exercise 5 (rated 25): what is it asking?	Combine a small fixed stack with link reversal for marking. Close to what real collectors do.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.5 cracked.guide::kind::exercise
TAOCP §2.3.5, exercise 7 (rated 24): what is it asking?	Marking without a stack when nodes have fewer spare fields.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.5 cracked.guide::kind::exercise
TAOCP §2.3.5, exercise 8 (rated 27, recommended): what is it asking?	Link-reversal marking for nodes of variable size.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.5 cracked.guide::kind::exercise
TAOCP §2.3.5, exercise 9 (rated 28, recommended): what is it asking?	Compact live nodes to one end of memory and fix up the links.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.5 cracked.guide::kind::exercise
TAOCP §2.3.5, exercise 10 (rated 28, recommended): what is it asking?	Copy a List structure that shares and even contains itself.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.5 cracked.guide::kind::exercise
TAOCP §2.3.5, exercise 12 (rated 30): what is it asking?	Make garbage collection safe for real-time use. The stretch: incremental collection before it had a name.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.5 cracked.guide::kind::exercise
TAOCP §2.3.5: how many exercises, and how are they rated?	12 exercises, rated 00 to M30.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.5 cracked.guide::kind::exercises
TAOCP §2.3.5: what should you be comfortable with first?	<ul><li>2.3.1 Traversing Binary Trees</li><li>Crafting Interpreters ch 26 (Garbage Collection)</li></ul>	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.5 cracked.guide::kind::prereqs
TAOCP §2.3.5: how should you work through it?	Compare Knuth's marking algorithms to your clox gray stack. Trace the link-reversal marking algorithm on a small graph on paper; it is tricky and worth drawing every step.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.3.5 cracked.guide::kind::approach
