What are Stacks in Data Structures?

A stack is a linear structure or a list of elements in which an element may be inserted or deleted only at one end, called the top of the stack. This means, stack is a type of data structure in which last element to be added is the first element to get service or removed. The elements are removed from a stack in the reverse order of that in which they were inserted into the stack.

Stacks in data structures
Stacks In Data Structures

Accordingly, stacks are also called ‘Last-In-First-Out (LIFO)’ lists. Other names used for stacks are “piles” and “push-down lists”. The stack may seem to be a very restricted type of data structure.

Special terminology is used for two basic operations associated with stacks:
  1. “Push” is the term used to insert an element into a stack.
  2. “Pop” is the term used to delete an element from a stack.
Powered by Blogger.