# Stack

We have seen the in-order traversal of a binary tree. It is a recursive code. Recursion stack can be simulated using an explicit Stack data structure and keeping the function non-recursive. Let us see how:

A valid mathematical expression can also have duplicate parenthesis as shown below: ((a+b)) (((a+(b)))+(c+d)) Write code to find if an expression has duplicate parenthesis. You may assume that expression does not have any white spaces.

Given an expression in postfix notation, write code to evalute a mathematical expression given in postfix notation. For Example: Input: 4 2 3 + * 6 – Output: 14

Given an arithmetic expression in in-fix notation. Write code to convert that algorithm in corresponding post-fix notation. For example: Infix Postfix —— ——– a+b ab+ (a+b)*c ab+c* a+b*c abc*+ a*(b+c)-d/e abc+*de/-

We have seen the code to implement a Queue using two stacks. This question is opposite of that. Use only Queue data structure to implement a Stack.