The best programs are written so that computing machines can perform them quickly and so that human beings can understand them clearly. A programmer is ideally an essayist who works with traditional aesthetic and literary forms as well as mathematical concepts, to communicate the way that an algorithm works and to convince a reader that the results will be correct. ― Donald E. Knuth

# Algorithms

## Stacks & Queues

Problem :-
Convert infix expression to the postfix notation.

Solution :-
Postfix notation is also known as Reverse Polish Notation (RPN) in which every operator follows all of its operands. This notation is parenthesis free.
For e.g, (A + B) is expressed as AB+ in postfix notation.
We use the following straight-forward algorithm to convert infix expression to a postfix expression :-
1) Scan the given expression from left to right.
2) First operator seen is simply pushed onto stack.
3) If we see an operand, append it to the postfix expression.
4) If we see an operator (x), pop off all the operators which are of lower precedence than 'x' and append them to the postfix expression. Then, push the operator 'x' onto stack.
5) If we see an opening parenthesis, simply push it onto stack.
6) If we see a closing parenthesis, pop off all elements from stack till opening parenthesis and append them to postfix expression except the opening & closing parenthesis.
7) Finally, pop off all the elements (operators) from stack till it's empty and append them to postfix expression.