GATE / CS ARCHIVE

GATE CSE 1997 / QUESTION 1.7

Infix-to-postfix conversion storage

Data Structures · Stacks & Queues · Full GATE CSE 1997 paper

GATE 1997, Q1.7 1 mark · MCQ
Report issue

Stacks & Queues

Question 1.7, GATE 1997: Which structure is essential for efficient infix-to-postfix conversion: operator stack, operand stack, both stacks, or parse tree?
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Operands can be emitted directly to the postfix output. Operators must wait until higher-precedence operators and parenthesized subexpressions are resolved, so a stack stores pending operators and delimiters. When an operator is popped, it is appended to the output. Thus the standard shunting-yard conversion needs an operator stack, A, not an operand-value stack. An operand stack is used later to evaluate postfix, and an explicit parse tree is an alternative representation rather than a requirement of this direct conversion.

Original paper, page 1