‹ Back to the paper
Question 2(i)
2 marks
Computer ScienceISC 2024 Specimen Computer Science Paper 1ConversionData structures
Convert the following.
Convert the following infix notation to postfix form. ( A / B + C ) / ( D * ( E − F )
Answer
Answer
The printed expression is missing a closing bracket; taking the evidently intended, balanced expression $(A/B+C)/(D*(E-F))$ and converting using operator precedence and left-to-right scanning with a stack:
$(A/B+C) \to A\ B\ /\ C\ +$
$(E-F) \to E\ F\ -$
$(D*(E-F)) \to D\ E\ F\ -\ *$
Combining the two parts with the outer $/$:
Postfix: $A\ B\ /\ C\ +\ D\ E\ F\ -\ *\ /$