Skip to main contentSkip to solution

While conversion of an infix notation to its equivalent Prefix/Postfix notation, what is pushed onto the stack ?

Solution

✅ Correct Option: 2

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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question