CH Datastructure Stack
CH Datastructure Stack
Stack
• Expression Evaluation
• Expression Conversion
• Parenthesis Checking
• String Reversal
• Function Call
Operations on Stack
The Stack supports the following standard operations:
push: Pushes an item at the top of the Stack. It returns an error if the
Stack is overflow.
pop: Remove and return the item from the top of the Stack. It
produces an error if the Stack is appeared to be underflow.
peek: Returns the item at the top of the Stack without removing it.
size: Returns the total number of items in the Stack.
isEmpty: Checks whether the Stack is empty.
isFull: Checks whether the Stack is full
Overflow: Overflow refers to condition when one tries to PUSH an item in Stack
which is full already
Underflow: Underflow refers to condition when one tries to POP an item from an
empty Stack
Implementation of Stack
Key Words:
Postfix notation refers when operator is placed after its operands e.g. ab+
Prefix notation refers when operator is placed before its operands e.g. +ab.
Infix notation refers when operator is placed between its operands e.g. a+b.
While conversion of an Infix notation to its equivalent Prefix/Postfix
notation, only operators are Pushed onto the Stack
Nested lists: When one or more elements of list is another list, it is called a
nested list.