Skip to content
Official PYQ · 1997

GATE CS 1997 Q1.7 — Arrays, Stacks and Queues

Explain with AI

Which of the following is essential for converting an infix expression to the postfix form efficiently?

Choose one option
View worked solution

Answer: A

The correct option is A.

To convert an infix expression to a postfix expression efficiently (typically using the Shunting-yard algorithm), we scan the infix expression from left to right:

  • Operands (like constants or variables) are immediately appended directly to the output postfix expression. They do not need to be stored or buffered in any stack.
  • Operators (and parentheses) must be temporarily stored to respect operator precedence and associativity. They are pushed onto a stack and popped to the output when an operator of lower or equal precedence is encountered.

Thus, only an operator stack is essential for the conversion process.


Why other options are incorrect:

  • Option B & C: An operand stack is used during the evaluation of a postfix expression, not during the conversion from infix to postfix.
  • Option D: While a parse tree can be used to represent the expression and generate postfix code via post-order traversal, building a parse tree is computationally heavier and less efficient than a single-pass stack-based algorithm.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Arrays, Stacks and Queues questions