in Others edited by
453 views
1 vote
1 vote

$\text{ABC}{\ast}+$ is the postfix form of :

  1. $ \text{A}\;{\ast}\; \text{B} + \text{C} $
  2. $ \text{A}{\ast} + \text{BC} $
  3. $ \text{A} + \text{B}\;{\ast}\; \text{C} $
  4. none of these
in Others edited by
453 views

1 comment

Answer:C
0
0

1 Answer

3 votes
3 votes

I always solve these type of questions using stack. If the given expression is postfix expression, traverse from left to right and if the given expression is prefix expression, traverse from right to left.

For this, we’ll traverse from left to right and when we encounter the operator, we will put the top operand to right of the operator and second most top element to the left of the operator and push back the result into stack. See the image below.

 

 

 

 

 

 

 

 

 

For the given question, the procedure will look like this:-

 

 

 

 

 

 

 

So the correct option is C.

edited by

Related questions