PadhaikoAll subjects

Past exam question: 2066 Bhadra (Regular / Back), Q2

Data Structure and Algorithms · 4 marks

Open in the Padhaiko app

Topic: Definition of stack and its operations · Array implementation of…

Question

Convert the following expression to postfix and prefix: ((A+B)*C-(D-E))\$(F+G)

Solution

1. Conversion to Postfix (((A+B)*C-(D-E))\$(F+G)): Sub-expression breakdown & stack precedence (\$ has higher precedence than *, /, which have higher precedence than +, -):

2. Conversion to Prefix: Reversing the infix expression ((G+F)\$((E-D)-C*(B+A))), converting to postfix, and reversing back:

Answer:

All past exam questions for Data Structure and Algorithms