KnowledgeBoat Logo
|

Computer Science

Convert the following infix notation to postfix notation, showing stack and string contents at each step.

A * (( C + D)/E)

Python Stack

11 Likes

Answer

Given,

A * (( C + D)/E)

Scanning from left to right:

SymbolActionStackPostfix Expression
AA
*Push*
(Push(*
(Push((*
CAC
+Push+((*
DACD
)Pop till one opening bracket is popped and add popped operator to expression(*ACD+
/Push/(*
EACD+E
)Pop till one opening bracket is popped and add popped operator to expression*ACD+E/
End of expressionPop all and add to expression#EmptyACD+E/*

Postfix notation of A * (( C + D)/E) = ACD+E/*

Answered By

5 Likes


Related Questions