Which data structure can be used to evaluate the postfix expression A B + C D…
2012
Which data structure can be used to evaluate the postfix expression A B + C D - *?
Answer: A. stack — ConceptPostfix evaluation processes tokens from left to right. Each operand is stored until an operator consumes the two most recent unresolved values, so the…
- A.
stack
- B.
tree
- C.
queue
- D.
linked list
Attempted by 362 students.
Show answer & explanation
Correct answer: A
Concept
Postfix evaluation processes tokens from left to right.
Each operand is stored until an operator consumes the two most recent unresolved values, so the required access rule is last-in, first-out.
Application
Apply that rule to A B + C D - *:
Read A and B and store them as unresolved operands.
At +, remove B and then A, form (A + B), and store that intermediate result.
Read C and D and store them as unresolved operands.
At -, remove D and then C, form (C - D), and store that intermediate result.
At *, remove the two intermediate results and form (A + B) * (C - D).
Cross-check
Every operator consumes the newest unresolved operands first. FIFO access would consume older values in the wrong order, while hierarchical or linked storage is not required for this evaluation rule.
Therefore, the postfix expression is evaluated using a stack.