MENU
Question -

Convert the following infix expression to its equivalent postfix expression, showing the stack contents for each step of conversion:
X/Y+U*(V-W)



Answer -

X / Y + U* (V – W) =((X / Y) + (U * (V – W)))

Element

Stack

Postfix

(

(

X

X

/

/

X

Y

/

XY

)

XY/

+

+

XY/

(

+

XY/

U

+

XY/U

*

+ *

XY/U

(

+ *

XY/U

V

+ *

XY/UV

+ *-

XY/UV

W

+ *-

XY/UVW

)

+ *

XY/UVW-

)

+

XY/UVW-*

)

it

XY/UVW-* +

OR

Element

Stack

Postfix

X

X

/

/

X

Y

/

XY

+

+

XY/

U

+

XY/U

*

+ *

XY/U

(

+ *(

XY/U

V

+ *(

XY/UV

+ *(-

XY/UV

w

+ ‘(-

XY/UVW

)

+ *

XY/UVW-

XY/UW-*

XY/UVW-* +

OR

Any other method orconverting the given Infix expression to its equivalent Postfix expressionshowing stack contents

 

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×