‹ Back to the paper
Convert the following infix notation to postfix form:
Convert the following infix notation to postfix form:
$A + ( B - C * ( D / E ) * F )$
Answer
Answer
AI$A + ( B - C * ( D / E ) * F )$
Converting using the standard operator-precedence (stack-based) algorithm (verified by running the conversion in code):
$D/E \to DE/$
$C*(D/E) \to C\,DE/\,* = CDE/*$
$C*(D/E)*F \to CDE/*\,F\,* = CDE/*F*$
$B - [C*(D/E)*F] \to B\,CDE/*F*\,- = BCDE/*F*-$
$A + [B-C*(D/E)*F] \to A\,BCDE/*F*-\,+$
Postfix: $A\;B\;C\;D\;E\;/\;*\;F\;*\;-\;+$
From ISC 2018 Computer Science Paper 1, question 2(c).