Group Discounts available for 3+ students and Corporate Clients

Stacks in Data Structures

In this tutorial, we will discuss about stacks in data structures.

A stack is an ordered list in which items may be added or removed only at one end, called the “top” of the stack.

The last item to be added to a stack is the first item to be removed .Accordingly, stacks are also called Last- in-first- out (LIFO) lists or First- in –out (FIFO) lists.





The two basic operation associated with stack are

  1. “Push” is the term used to insert an element into a stock.
  2. “Pop” is the term used to delete an element into a stack.



  1. A stack of dishes
  2. A stack of coins
  3. A stack of folded towels
  4. A stack of bills
  5. A railway system for shunting cars.


  • Stack may be represented in a computer in various ways, usually by means of a one –dimensional array and linked list.
  • “Top” is variable or a pointer, which points top most element of the stack.
  • Initially when the stack is empty, “Top has a value of “-1” and when the stack contains a single element.
  • “Top” has a value of “0” and when the stack contains two elements, “Top” has value of “1” and so on.
  • The following is the condition to test the stack is full or not( Top== maxsize-1)
  • Each time a new element is inserted in the stack, the top is incremented by “one” before the elements is placed on the stack.


  • The following is the condition to kept the stack is empty or not.


  • The “Top “is decremented by one each time a deletion is made from the stack.

Top =Top-1;

  • A variable “max size “, which gives the maximum number of elements that can be held by the stack.



“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at, we will update the article in 24 hours.”

0 Responses on Stacks in Data Structures"

Leave a Message

Your email address will not be published. Required fields are marked *


Please Enter Your Details and Query.
Three + 6