Why Trust Techopedia

What Does Stack Mean?

A stack is a logical concept that consists of a set of similar elements. The term is often used in programming and memory organization in computers.


Programming stacks are based on the principle of last in first out (LIFO), a commonly used type of data abstract that consists of two major operations, push and pop. The push operation adds an element to the bottom of stack while the pop operation removes an element from the top position.

Software implementations of the stack concept are done using arrays and linked lists where the top position is tracked using a variable or header pointer respectively. Many programming languages provide built-in features to support stack implementation.

In information and communication technology (ICT), well-known types of stacks include:

Software stacks – programming components that work together to support an application’s execution. LAMP (Linux, Apache, MYSQL, Perl or PHP or Python) is a popular software stack.

Full stacks – all the front-end and back-end technologies and skills that support an IT objective.

Protocol stacks – interconnectivity rules for a layered network model such as TCP/IP or Open Systems Interconnection (OSI). To become a stack, the protocols must be interoperable vertically between the layers of the network and horizontally between the end-points of each transmission segment.

Techopedia Explains Stack

In programming, a stack is a buffer that is used to temporarily store requests. This type of stack has a bounded bottom and all the operations are carried out on the top position. Whenever an element is added to the stack by the push operation, the top value is incremented by one, and when an element is popped out from the stack, the top value is decremented by one. A pointer to the top position of the stack is also known as the stack pointer.

Buffer stacks can be fixed in size or dynamic. Stack registers are used to store the value of the stack pointer.

In the case of bounded capacity stacks, trying to add an element to an already full stack causes a stack overflow exception. Similarly, a condition where a pop operation tries to remove an element from an already empty stack is known as underflow.

A stack is considered to be a restricted data structure as only a limited number of operations are allowed. Besides the push and pop operations, certain implementations may allow for advanced operations such as:

  • Peek — View the topmost item in the stack.
  • Duplicate — Copy the top item’s value into a variable and push it back into the stack.
  • Swap — Swap the two topmost items in the stack.
  • Rotate — Move the topmost elements in the stack as specified by a number or move in a rotating fashion.

Related Terms

Margaret Rouse

Margaret jest nagradzaną technical writerką, nauczycielką i wykładowczynią. Jest znana z tego, że potrafi w prostych słowach pzybliżyć złożone pojęcia techniczne słuchaczom ze świata biznesu. Od dwudziestu lat jej definicje pojęć z dziedziny IT są publikowane przez Que w encyklopedii terminów technologicznych, a także cytowane w artykułach ukazujących się w New York Times, w magazynie Time, USA Today, ZDNet, a także w magazynach PC i Discovery. Margaret dołączyła do zespołu Techopedii w roku 2011. Margaret lubi pomagać znaleźć wspólny język specjalistom ze świata biznesu i IT. W swojej pracy, jak sama mówi, buduje mosty między tymi dwiema domenami, w ten…