In Reverse Polish notation, the expression A∗B+C∗D is written as:
2023
In Reverse Polish notation, the expression A∗B+C∗D is written as:
- A.
AB∗CD∗+
- B.
A∗BCD∗+
- C.
AB∗CD+∗
- D.
A∗B∗CD+
Attempted by 433 students.
Show answer & explanation
Correct answer: A
Concept: Reverse Polish notation (postfix) writes every operator immediately after its two operands, with no parentheses. To convert an infix expression you must first apply operator precedence and associativity to fix the order of evaluation: in A∗B+C∗D the multiplication operator (∗) binds tighter than addition (+), so the expression groups as (A∗B)+(C∗D).
Application — convert one operator at a time:
Evaluate the higher-precedence multiplications first. The left product A∗B becomes the postfix sub-expression AB∗ (operands A and B, then the operator).
The right product C∗D becomes the postfix sub-expression CD∗ in the same way.
The addition runs last, on the two products. Place its operands AB∗ and CD∗ side by side and append the + operator after them, giving AB∗CD∗+.
Cross-check by evaluating the postfix string AB∗CD∗+ on a stack, scanning left to right:
Push A, push B; the ∗ pops B and A and pushes the product (A∗B).
Push C, push D; the next ∗ pops D and C and pushes the product (C∗D).
The final + pops (C∗D) and (A∗B) and pushes their sum.
The single value left on the stack is (A∗B)+(C∗D), which matches the original infix expression — confirming AB∗CD∗+ is the correct postfix form.