GATE Computer ScienceModerateGATE CS (PYQ pattern)

Convert the infix expression a - b * c / d + e * (f - g) / h (all binary operators left-associative; * and / bind tighter than + and -) to postfix. What is the result?

  1. A. abc*d/-efg-*h/+
  2. B. abcd/*-efg-*h/+
  3. C. abc*d/-efg-h/*+
  4. D. abc*d/-e*fg-h/+

Correct answer: A. abc*d/-efg-*h/+

Equal-precedence operators pop left to right. The result is abc*d/-efg-*h/+.

More Programming and Data Structures (GATE) questions

Exams that ask this topic