#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::TAOCP Vol 1::2.2.3 Linked Allocation
#columns:Front	Back	Tags
TAOCP §2.2.3 Linked Allocation: what does it cover?	Linked lists, the available-space (free) list, and how to implement stacks and queues with links. The highlight is topological sorting: putting items in an order consistent with a set of &quot;must come before&quot; relations.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.3 cracked.guide::kind::about
TAOCP §2.2.3: why does it matter?	Topological sort runs your build system, package manager and task scheduler. Free lists are the simplest memory allocator and still used in game engines and kernels.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.3 cracked.guide::kind::why
Topological sort: what is it?	A topological sort arranges the items of a partial order (or the vertices of a directed acyclic graph) in a sequence where every item comes after all the items that must precede it.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.3 cracked.guide::kind::definition
Topological sort: Is the topological order unique?	Only when the relations force a single chain. Usually many orders are valid, and which one you get depends on how ties are broken.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.3 cracked.guide::kind::definition
TAOCP §2.2.3: what traps should you watch for?	<ul><li>Losing nodes when you forget to return them to the free list.</li><li>Topological sort with a cycle in the input: decide what your code should do.</li></ul>	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.3 cracked.guide::kind::traps
TAOCP §2.2.3, exercise 1 (rated 10, recommended): what is it asking?	Why the linked push never mentions overflow in the text's notation.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.3 cracked.guide::kind::exercise
TAOCP §2.2.3, exercise 7 (rated 23): what is it asking?	Reverse a singly linked list in place. The classic.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.3 cracked.guide::kind::exercise
TAOCP §2.2.3, exercise 2 (rated 22): what is it asking?	Write a general MIX insertion subroutine with the book's calling conventions.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.3 cracked.guide::kind::exercise
TAOCP §2.2.3, exercise 11 (rated 24, recommended): what is it asking?	List every valid topological order for a small example.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.3 cracked.guide::kind::exercise
TAOCP §2.2.3, exercise 17 (rated 21, recommended): what is it asking?	Run the topological sort by hand on the text's input.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.3 cracked.guide::kind::exercise
TAOCP §2.2.3, exercise 20 (rated 24, recommended): what is it asking?	Swap the queue inside topological sort for a stack and compare the results.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.3 cracked.guide::kind::exercise
TAOCP §2.2.3, exercise 29 (rated 21, recommended): what is it asking?	Return a whole list to the free list as fast as possible.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.3 cracked.guide::kind::exercise
TAOCP §2.2.3, exercise 23 (rated 27, recommended): what is it asking?	Make topological sort print an actual cycle when it gets stuck. The stretch, and a feature every build tool needs.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.3 cracked.guide::kind::exercise
TAOCP §2.2.3: how many exercises, and how are they rated?	30 exercises, rated 10 to M48.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.3 cracked.guide::kind::exercises
TAOCP §2.2.3: what should you be comfortable with first?	<ul><li>2.2.2 Sequential Allocation</li><li>C pointers (clox)</li></ul>	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.3 cracked.guide::kind::prereqs
TAOCP §2.2.3: how should you work through it?	This is a long and very rewarding section. Implement the free-list allocator in C. Then implement Knuth's topological sort algorithm from the text, run it on a small dependency graph from a real project, and check the output order.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.3 cracked.guide::kind::approach
