Stack
noun
say it: “STAK” /stæk/
A last-in, first-out collection: items are pushed on top and popped off the top.
What is a stack?
A stack keeps items last in, first out, like a stack of plates: you push an item on top, pop the top item off, and peek at the top without taking it. All three are O(1). Undo buttons, a browser's back button, bracket matching and the call stack are all stacks.
In a sentence
- “The editor keeps every change on a stack, so undo always reverses the newest one first.”
Level: Apprentice · More Data Structures terms at this level
Updated