Skip to main contentSkip to solution

While conversion of an Infix notation to its equivalent Prefix/Postfix notation, only ________ are ______ onto the stack.

Solution

✅ Correct Option: 2

While converting infix to postfix or prefix, operands go straight to the output. Only operators (and parentheses) are PUSHed onto the stack, and they are POPed to the output according to precedence and associativity.

For example, A+B∗CA + B * C becomes ABC∗+ABC*+. Here AA, BB, CC go to the output directly, while ++ and ∗* wait on the stack.


Option 1: operands are never stacked in this conversion. They are written to the output as soon as they are read. (Operands are pushed only when evaluating a postfix or prefix expression.)

Options 3 and 4: POP is the step that moves operators from the stack to the output, so it is not the operation that "puts onto" the stack.

Keyboard Shortcuts

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