← Stacks · guided lesson

Stacks & Monotonic Stack

1 / 18 · story

the story

Stack (last in, first out)

Every tool here exists because something was too slow or broke without it. Here is what.

1955–1960 · Friedrich L. Bauer & Klaus Samelson

In Munich, from 1955, Bauer and Samelson wanted to translate formulas like a × (b + c) into machine code in one left-to-right pass. Their trick: put each operator that can't run yet into a "Keller" (German for cellar) and take out the most recent one first. They filed a German patent on this principle on 30 March 1957, and described it in English in "Sequential formula translation" (CACM, 1960). Bauer's 1988 IEEE Computer Pioneer Award reads simply: "For computer stacks."

the problem it solved

Translating formulas with nested parentheses and operator precedence in one left-to-right pass, by postponing each operator until it can be applied.

why it matters: without it

Every "most recent first" job — nesting, undo, method calls — would need its own bookkeeping, and bracket checks would be quadratic.

sources: Bauer & Samelson — German patent DE 1094019 (filed 30 March 1957) ↗ · Samelson & Bauer — Sequential formula translation (CACM, 1960) ↗ · IEEE Computer Society — Friedrich L. Bauer, Computer Pioneer Award ↗ · Wikipedia — Stack (abstract data type): History (the 1955 "Operationskeller" proposal) ↗

also in this chapter: Reverse Polish notation & the operand stack · Monotonic stack · ArrayDeque (and why not java.util.Stack)