STACK: LIFO / PTR: TOP
QUEUE: FIFO / PTR: FRONT, REAR
CIRCULAR: (REAR+1)%N
STATE: BOUNDED
ASKiIMAN™ DOOR 04 / THE CODE / REALM 04
--:-- · -- --- ----

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.

DATA SET → ACCESS RESTRICTION → LIFO (STACK) vs FIFO (QUEUE) → POINTER CONTROL → BOUNDARY CHECKS → EXPRESSION EVALUATION → SCHEDULING

The 11 Discipline Nodes

Ontological Mapping: Linear Data Control

GROUP 01

LIFO Stack Concept

  • Last-In, First-Out logic
  • Push operation (Insert)
  • Pop operation (Remove)
  • Peek / Top (Access)
GROUP 01

Array Implementation

  • Static memory allocation
  • Top index pointer
  • Top = -1 (Empty state)
  • Top = N-1 (Full state)
GROUP 02

Infix to Postfix

  • Expression formats (In/Pre/Post)
  • Operator precedence handling
  • Parentheses resolution
  • Stack holds pending operators
GROUP 02

Postfix Evaluation

  • Machine execution of math
  • Operands pushed to stack
  • Operators pop operands & eval
  • Final result remains at Top
GROUP 03

FIFO Queue Concept

  • First-In, First-Out logic
  • Enqueue (Insert at Rear)
  • Dequeue (Remove from Front)
  • Dual-pointer mechanism
GROUP 03

Circular Queues

  • Solves linear queue wasted space
  • Rear wraps to beginning
  • Modulo arithmetic (Rear+1)%N
  • Full condition (Front == Rear+1)
GROUP 01 & 03

Boundary Conditions

  • Overflow: Insert into full structure
  • Underflow: Delete from empty structure
  • Critical error handling
  • Bounded vs Unbounded capacity
GROUP 04

Priority Queues

  • Elements ordered by priority, not time
  • Highest priority dequeued first
  • Operating system task scheduling
  • Bridge to Heaps (Realm 05)
GROUP 04

Deques

  • Double-Ended Queue
  • Insert/Delete at FRONT
  • Insert/Delete at REAR
  • Input/Output restricted variants
VARIOUS

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
FINAL PROTOCOL

11 — The Linear Discipline Lab

1. PUSH(A), PUSH(B), POP() -> [A]
2. ENQ(1), ENQ(2), DEQ() -> [2]
3. CIRC: REAR = (REAR+1)%MAX
[1] TRACE STACK STATE [2] EVALUATE POSTFIX [3] MANAGE QUEUE POINTERS [4] DETECT OVERFLOW [5] IMPLEMENT DEQUE

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.

SIMULATION RUNNING