Professional Documents
Culture Documents
CB_STACKS
CB_STACKS
CB_STACKS
#include<stack>
1. Define the name and type of data
stack<int>numbersStack;
• numbersStack.push(1);
numbers.Stack(pop);
Printing the elements of Stack
• void printStackElements(Stack<int> stack)
{
while(!stack.empty())
{
cout<<Stack.top()<<endl;
stack.pop();
}
}
Invoking the function
printStackElements(numbersStack);
POLISH NOTATIONS
• INFIX EXPRESSION
• PREFIX EXPRESSION
• POSTFIX EXPRESSION
PRECEDENCE OF OPERATORS
• PARANTHESIS
• EXPONENT
• MULTIPLICATION AND DIVISION
• ADDITION AND SUBSTRACTION
Polish Notation
• Infix Notation: Operator symbol is placed between
the two operands.
Example:
(5 * 3) + 2 & 5 * (3 + 2)
Polish Notation
Polish Notation: The Operator Symbol is placed before
its two operands.
• A + (B * C) = ___________
• (A + B) / (C - D) = ____________
Reverse Polish Notation
Reverse Polish Notation: The Operator Symbol is placed after
its two operands.
5*(6+2) – 12/4