Stack

A stack is a data structure where items are added and removed from the same end, following Last-In-First-Out (LIFO) order — like a stack of plates.

General Programming

The two main operations are push (add to the top) and pop (remove from the top). Stacks power undo features, browser back buttons, and the call stack that tracks function calls.

Examples

Python

stack = []
stack.append("a")
stack.append("b")
print(stack.pop())

Output:

b

See also

Back to the Dictionary