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.
- The stack of trays in a cafeteria
- 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 ...