Converting an infix expression to postfix
-
05-11-2019 - |
Question
So the question is to convert the following expression to postfix:
(a+b)^(p+q)^(r*s*t)
The answer I get when I calculate is: ab+pq+^rs*t*^
But the answer is given to be ab+pq+rs*t*^^
I assume that the step when you need to push second '^' into stack when there is already a '^' in the stack is where I went wrong (I pop out the '^' before pushing). Shouldn't we pop out the first '^' as they are of equal precedence ? Or is it an exception to '^' operator ?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with cs.stackexchange