Make Your Search Easy ! :) Use me

Wednesday, February 22, 2017

Postfix - Infix

Change  ( ( A + B ) * C + D / E - F ) into postfix expression :-



Symbol Scanned
Operation
Stack
Expression
(
Push to Stack
(

(
Push to Stack
( (

A
Add to Expression
( (
A
+
Push to Stack
( ( +
A
B
Add to Expression
( ( +
A B
)
Pop ‘+’
(
A B +
*
Push to Stack
( *
A B +
C
Add to Expression
( *
A B + C
+
Push to Stack and
Pop ‘*’
( +
A B + C *
D
Add to Expression
( +
A B + C * D
/
Push to Stack
( + /
A B + C * D
E
Add to Expression
( ( + /
A B + C * D E
-
Push to Stack and
Pop ‘/’ and ‘+’
( -
A B + C * D E / +
F
Add to Expression
( -
 A B + C *D E / + F
)
Pop ‘-‘

A B + C * D E / + F -

No comments:

Post a Comment