While conversion of an infix notation to its equivalent Prefix/Postfix notation, what is pushed onto the stack ?
While conversion of an infix notation to its equivalent Prefix/Postfix notation, what is pushed onto the stack ?
Solution
During infix to postfix (or prefix) conversion, operands are sent straight to the output as they are read. Only operators (and parentheses, which act as markers) are held on the stack, so that precedence and associativity can decide when each operator is popped to the output.
Option 1: operands never wait on the stack here; they go directly to the output. Operand stacks are used when evaluating a postfix/prefix expression, which is a different task.
Option 3: this mixes up conversion with evaluation. Only evaluation pushes operands.
Option 4: parentheses do go on the stack, but operators are the main items stored, so "only special symbols" is wrong.
Related questions:
2026: 20 May Shift 1
2026: 26 May Shift 1
2025: 16 May Shift 1
2026: 13 May Shift 2
2026: 11 May Shift 2