‹ Back to the paper
Question 2(i)
2 marks
Computer ScienceISC 2023 Computer Science Paper 1ConversionData structures
Answer the following.
Convert the following infix notation to prefix notation. (A - B) / C * (D + E)
Convert the following infix notation to prefix notation.
$(A - B) / C * (D + E)$
Answer
Answer
$(A - B) / C * (D + E)$; / and * have equal priority and are evaluated left to right, so it is $((A - B) / C) * (D + E)$.
Step 1: $(A - B) \to -AB$ and $(D + E) \to +DE$
Step 2: $(-AB) / C \to /-ABC$
Step 3: $(/-ABC) * (+DE) \to */-ABC+DE$
Prefix: $* \, / \, - \, A \, B \, C \, + \, D \, E$