# Stacks & Queues **Track:** Objects, Data Structures & Algorithms — Creative Coding — the existing 50 **Framework / surface:** p5.js **Level:** Intermediate **Prerequisites:** Arrays **In one line:** Last-in-first-out vs first-in-first-out — each right for different jobs. ## Theory, aesthetics & inspiration A stack and a queue are the same idea—an ordered collection—governed by opposite disciplines: last-in-first-out versus first-in-first-out. The stack models nesting and undo, and underlies expression evaluation and the call stack that tracks a program's own recursion; the queue models fairness and scheduling, serving what arrived first. Donald Knuth's "The Art of Computer Programming" treats both as foundational, and Dijkstra's work on stack-based evaluation made the structure central to how machines parse. The aesthetic lesson is that order is a constraint that creates meaning: by choosing which end to enter and leave, the same data yields entirely different temporal behavior.