Question & Answer: 1. In order to write an RPN calculator one needs to declare…..

1. In order to write an RPN calculator one needs to declare

A. a single stack capable of holding the numers

B. a stack for the numbers and a stack for the operators

C. only a stack for the operators since the numbers are immediately output

D. a stack for operators, a stack for numbers and a stack to hold the results of these operations.

Expert Answer

 

RPN means Reverse polish notation, in order to write a RPN calculator one needs to declare:

the answer is A i.e. a single stack of numbers for example

to evaluate expression 5 6 + thefollowing steps will be performed:

  • push 5 on the stack
  • push 6 on the stack
  • pop the two topmost stack values and apply + operator and the push the result(11) on the top of the stack
Still stressed from student homework?
Get quality assistance from academic writers!