Chapter 6


Stack data structure is exclusively discussed in this chapter. Representation and implementation of stacks are explained along with examples. Four of the common applications are stated and illustrated in detail.


A stack is a linear data structure in which insertion and deletion of elements are done at only one end, which is termed as Top of stack. The last element that is inserted will be the first element to be deleted. Therefore, this is referred to as a Last In First Out (LIFO) structure.


  1. The stack of trays in a cafeteria
  2. A stack of plates in a cupboard

Let ST be a stack with elements 10, 20, 30. The element 30 is pointed by the top. When the new element 40 is to be added, it is inserted at the ...

Get Data Structures and Algorithms Using C++ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.