Professional Documents
Culture Documents
25 59 43
The top most accessible position of the stack is called the Top of the
Bottom
stack and the first item’s position is called Bottom
Top of the stack.
Basic Features of Stack
Following are the basic features of stack:
1. Stack is an ordered list of items with similar data types.
2. Stack is a LIFO data structure (i.e. Items are accessed in last in first
out order).
3. The PUSH operation is used to insert new element into the stack and
POP operation is used to delete an element from the top of the stack.
(please note that Insertion and deletion are allowed at only one end
of the stack called top).
4. A stack is said to be in OVERFLOW state when it is completely full
whereas it is said to be in UNDERFLOW state when it is completely
empty.
Stack Operation
Two fundamental operations can be performed on the stack.
These operations are called PUSH and POP.
PUSH Operation
When a new data item is added or inserted into the stack at its
top is called PUSH operation.
Before pushing a data item into the stack it is ensured that there
is an available location in the stack to store that item .
If there is no room, no further value can be pushed on the stack.
This situation or condition is called “stack overflow”.
In this case “Stack overflow” message is sent to the user.
Cont.
Top 9
Top 5 5
Top 8 8 8
Top 3 3 3 3
Top 7
2
2 Top 2
8
8
8 8 Top
3 3
3 3 3
Top
POSTFIX: operator comes after the operands, also Known as Reverse Polish
Notation (RPN).
PREFIX: operator comes before the operands, also Known as Polish notation.
Example
Infix: A+B-C Postfix: AB+C- Prefix: -+ABC