Which data structure is primarily used to evaluate a postfix expression?

Options

  • A. Queue
  • B. Tree
  • C. Stack
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. Stack

Detailed Explanation

Correct Answer: C. Stack

Explanation: A stack is used to evaluate postfix expressions.

  • Scan the expression from left to right.
  • Push operands onto the stack.
  • When an operator appears, pop the required operands, perform the operation and push the result.

Example: 23+ evaluates to 5.