UGC-NET Dec 2014 · Stacks

MCQ · 2 marks · Problem PROG-DSTR-0038

Convert the following infix expression into its equivalent post fix expression $ (A + B$^$ D) / (E – F) + G $
  1. A
    $ABD$^ $+EF – / G+$
  2. B
    $ABD + $^$EF – / G+$
  3. C
    $ABD +$ ^$EF / – G+$
  4. D
    $ABD$^ $+ EF / – G+$

Solve it on GATE DA practice →More Basic Data Structures problems

Show the worked solutionPrecedence: \(\wedge\) (exponent) highest, then \(/\), then \(+\); parentheses first.\[A+B\wedge D\ \to\ A\ B\ D\ \wedge\ +\]\[E-F\ \to\ E\ F\ -\]\[(A+B\wedge D)/(E-F)\ \to\ A\ B\ D\ \wedge\ +\ E\ F\ -\ /\]\[\ldots+G\ \to\ A\ B\ D\ \wedge\ +\ E\ F\ -\ /\ G\ +\]This is option A. (B), (C) apply \(+\) before \(\wedge\); (C), (D) apply \(/\) before \(-\).Answer: A

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com