Stack Chapter Modern Notes
Stack Chapter Modern Notes
1. Introduction to Stack:
- Definition: A Stack is a linear data structure that follows the LIFO (Last In, First Out) principle,
- Stack as an ADT: A Stack is an Abstract Data Type (ADT) that supports basic operations such as
Push (insert) and Pop (remove). It is commonly used in algorithm design and problem-solving.
2. Operations on Stack:
- Push: Adds an element to the top of the stack.
3. Conditions:
- Stack Full/Stack Overflow: Occurs when attempting to push an element onto a stack that is already
- Stack Empty/Stack Underflow: Happens when attempting to pop an element from an empty stack.
4. Stack Implementation:
- Using Array: The stack is implemented using a fixed-size array, where a 'top' variable keeps track
- Using Linked List: Each node contains data and a reference to the next node. The 'top' points to
5. Applications of Stack:
- Reversing a List: Elements of the list are pushed onto a stack and then popped to reverse the
order.
- Polish Notations: Used in evaluating and converting expressions between Prefix, Infix, and Postfix
notations.
- Conversion of Infix to Postfix Expression: Involves scanning the infix expression, using stack
operations to handle operators, and forming the postfix expression.