The Stack Data Structure
Table of Contents
1. The Stack Data Structure
1.1. Definition
A linear abstract data structure where the elements could be added or deleted only at one open end, called the top of the stack.
- The elements follow “The Last In First Out Order”, typically called
LIFO. - Insertion into the stack is called a
pushoperation, and deletion from the stack is called apopoperation. - If the stack is full, it is said to be in the
"Overflow"stage, andpushis rejected if the stack is overflow. - If the stack is empty, it is said to be in
"Underflow"state, andpopis rejected if the stack is underflow.
1.2. Algorithm for PUSH and POP Operations
1.2.1. Declaration
Let S be a stack of SIZE = 100 elements, and TOP is an integer to hold the index of the last inserted element into the stack. Initially, TOP = -1
1.2.2. Algorithm
| |