stack

A collection where the last item added is the first one removed, like a pile of plates.

In more detail

A stack supports push, to add on top, and pop, to remove from the top, both O(1). A Python list is an ideal stack: use append and pop at the end. Stacks power undo history, bracket matching, expression evaluation, depth-first search and the call stack itself.

Related terms

Taught in

References