Ontological Layer: Linear Access Disciplines
Stacks & Queues
The Mechanics of LIFO and FIFO Flow
The Rules of Entrance and Exit
Realm 03 taught us how to link data together. Realm 04 dictates the strict rules of how that data can be accessed. A Stack forces a Last-In, First-Out (LIFO) discipline, creating a temporary holding zone perfect for expression evaluation and function calls. A Queue mandates a First-In, First-Out (FIFO) discipline, forming the foundation of task scheduling and fair resource allocation.
The 11 Discipline Nodes
Ontological Mapping: Linear Data Control
LIFO Stack Concept
- Last-In, First-Out logic
- Push operation (Insert)
- Pop operation (Remove)
- Peek / Top (Access)
Array Implementation
- Static memory allocation
- Top index pointer
- Top = -1 (Empty state)
- Top = N-1 (Full state)
Infix to Postfix
- Expression formats (In/Pre/Post)
- Operator precedence handling
- Parentheses resolution
- Stack holds pending operators
Postfix Evaluation
- Machine execution of math
- Operands pushed to stack
- Operators pop operands & eval
- Final result remains at Top
FIFO Queue Concept
- First-In, First-Out logic
- Enqueue (Insert at Rear)
- Dequeue (Remove from Front)
- Dual-pointer mechanism
Circular Queues
- Solves linear queue wasted space
- Rear wraps to beginning
- Modulo arithmetic (Rear+1)%N
- Full condition (Front == Rear+1)
Boundary Conditions
- Overflow: Insert into full structure
- Underflow: Delete from empty structure
- Critical error handling
- Bounded vs Unbounded capacity
Priority Queues
- Elements ordered by priority, not time
- Highest priority dequeued first
- Operating system task scheduling
- Bridge to Heaps (Realm 05)
Deques
- Double-Ended Queue
- Insert/Delete at FRONT
- Insert/Delete at REAR
- Input/Output restricted variants
Implementation Choice
- Array: Fixed size, O(1) access
- Linked: Dynamic size, pointer overhead
- Array queues need shifting or circular logic
- Linked queues need simple pointer updates
11 — The Linear Discipline Lab
These access disciplines are the unseen engines of computation. The stack manages the deep recursion of functions and execution contexts, while the queue organizes the flow of asynchronous data and tasks. Understanding them prepares us for the hierarchical complexity of Trees & Heaps in Realm 05.