#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::TAOCP Vol 1::2.2.2 Sequential Allocation
#columns:Front	Back	Tags
TAOCP §2.2.2 Sequential Allocation: what does it cover?	Storing stacks and queues in contiguous memory, handling overflow, circular queues, and keeping several stacks in one shared region with a method for repacking memory when one stack runs out of room (Garwick's approach).	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.2 cracked.guide::kind::about
TAOCP §2.2.2: why does it matter?	Arrays beat linked structures for cache performance, so contiguous allocation and growth strategies are still very relevant. Think dynamic arrays, ring buffers and arena allocators.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.2 cracked.guide::kind::why
TAOCP §2.2.2: what traps should you watch for?	<ul><li>The classic circular-queue bug: not being able to tell full from empty.</li><li>Off-by-one on the boundary when two stacks meet.</li></ul>	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.2 cracked.guide::kind::traps
TAOCP §2.2.2, exercise 1 (rated 15, recommended): what is it asking?	Count how many items the circular queue holds before it reports overflow.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.2 cracked.guide::kind::exercise
TAOCP §2.2.2, exercise 2 (rated 22, recommended): what is it asking?	Extend the circular queue to a full deque.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.2 cracked.guide::kind::exercise
TAOCP §2.2.2, exercise 6 (rated 10): what is it asking?	Trace a sequence of operations on two stacks sharing memory and spot overflow.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.2 cracked.guide::kind::exercise
TAOCP §2.2.2, exercise 7 (rated 12): what is it asking?	Can the repacking algorithm ever divide by zero.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.2 cracked.guide::kind::exercise
TAOCP §2.2.2, exercise 16 (rated 20): what is it asking?	Can two queues, or a queue and a stack, share memory the way two stacks do.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.2 cracked.guide::kind::exercise
TAOCP §2.2.2, exercise 19 (rated 16, recommended): what is it asking?	Rewrite the stack and queue formulas with 0-based indexing and see what gets simpler.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.2 cracked.guide::kind::exercise
TAOCP §2.2.2, exercise 8 (rated 26, recommended): what is it asking?	Adapt the multi-stack repacking to tables that are circular queues.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.2 cracked.guide::kind::exercise
TAOCP §2.2.2, exercise 18 (rated M30, recommended): what is it asking?	Bound the total running time of the repacking scheme. The stretch.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.2 cracked.guide::kind::exercise
TAOCP §2.2.2: how many exercises, and how are they rated?	19 exercises, rated 10 to HM43.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.2 cracked.guide::kind::exercises
TAOCP §2.2.2: what should you be comfortable with first?	<ul><li>2.2.1 Stacks, Queues, and Deques</li></ul>	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.2 cracked.guide::kind::prereqs
TAOCP §2.2.2: how should you work through it?	Implement a circular queue with an explicit full and empty test. Then implement two stacks growing toward each other in one array. The multi-stack repacking algorithm is worth tracing by hand once; the analysis can be read lightly.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::2.2.2 cracked.guide::kind::approach
