Understanding Stack Essentials
A stack is a LIFO (last in, first out) linear data structure. In my head, a “classical” stack is an array-like collection of cells that supports only three operations:
-
push(item). Push the item onto the stack, making it the top item of the stack (“last in”).
-
pop. Remove the top item from the stack (“first out”).
-
empty. Check if the stack is empty (whether it has the top item).
Stacks as data structures have been known before their software implementations. Stack automata and stack-based pushdown automata play an essential role in the theory of computation. The pushdown automaton was introduced by Allen Newell in 1959 and mentioned in the context of theoretical computer science by Edsger Dijkstra in 1960. However, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access