273 views
0 votes
0 votes
How can we evalute infix expression using stacks?

logic: we hv 2 stacks ( operator stack and operand stack )

traverse expression from left to right

if operand come push into operand stack and similar for operators

but if higher precedence opartor come and in operator stack there is an operator with lower precedence then put directly onto that

but if in operator stack there is an operator with higher precedence compare to coming opartor then put evalute higher precedence opartor then push new operator into operator stack

 

is it correct aproach?

1 Answer

Related questions