Section: IT & Technology · Software DevelopmentDifficulty: Easy

Stack

USUK

A last-in, first-out (LIFO) data structure where elements are added and removed from the top.

Also: call stack

Definition

A stack is an abstract data type that follows the Last-In, First-Out (LIFO) principle, where the most recently added element is the first to be removed. Core operations are push (add to top), pop (remove from top), and peek (view top without removing), all operating in O(1) time. Stacks are fundamental to function call management (call stack), expression evaluation, syntax parsing, undo mechanisms, and depth-first search algorithms. They can be implemented with arrays or linked lists.

Example

When a function calls another function, the current execution context is pushed onto the call stack; when the called function returns, its context is popped off, restoring the caller's state.

Synonyms

  • LIFO structure
  • push-pop stack
  • call stack

Antonyms / Opposites

  • queue
  • FIFO structure

Images

CC-licensed · free to use
More on Wikimedia
Loading images…

Video

  • data-structure
  • recursion
  • algorithm
  • queue-data

Dictionary Entry

Back to IT & Technology