‹ Back to the paper
Convert the following infix notation to postfix form.
Convert the following infix notation to postfix form.
$( P / Q - R ) * ( S + T )$
Answer
Answer
AI$(P/Q-R)*(S+T)$
Converting $(P/Q-R)$: push $($, output $P$, push $/$, output $Q$ (so far $PQ$), on seeing $-$ pop $/$ to output ($PQ/$) then push $-$, output $R$ ($PQ/R$), on $)$ pop $-$ ($PQ/R-$).
Converting $(S+T)$: output $ST+$.
Combine with $*$: $PQ/R- \;\; ST+ \;\; *$
Postfix: $PQ/R-ST+*$
From ISC 2023 Specimen Computer Science Paper 1, question 2(i).