Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4) [30 Points] Assuming tha a Reverse Polish Notation (RPN) expression (10 43 2 is represented by using two arrays: one for numbers, called rp
4) [30 Points] Assuming tha a Reverse Polish Notation (RPN) expression (10 43 2 is represented by using two arrays: one for numbers, called rp n (10, 4 3, MAX INT 2 MALINT, MAX-INT) and one for operations, called rpc-o( ! 1, ! . +, -). Note that non integers are replaced with MAX INT in the rpc n aray and numbers are replaced with ! in the rpe o one. Write a program to compute a RPN expression. (Hint Process the expression from left to right. Whenever a number is encountered, it has to be kept for operations. When an operator is encountered, perform the operation with the last two numbers and keep the resulting number for futher use. When you reach the end of the expression, a single number representing the result is left. An example for an RPN evaluation is given below. Assume that a user enters 10 4 3 + 2 and program reponds with-4) 1032 43- 2 10 4 0 4 3 0 7 2 0 14 10-1 4) [30 Points] Assuming tha a Reverse Polish Notation (RPN) expression (10 43 2 is represented by using two arrays: one for numbers, called rp n (10, 4 3, MAX INT 2 MALINT, MAX-INT) and one for operations, called rpc-o( ! 1, ! . +, -). Note that non integers are replaced with MAX INT in the rpc n aray and numbers are replaced with ! in the rpe o one. Write a program to compute a RPN expression. (Hint Process the expression from left to right. Whenever a number is encountered, it has to be kept for operations. When an operator is encountered, perform the operation with the last two numbers and keep the resulting number for futher use. When you reach the end of the expression, a single number representing the result is left. An example for an RPN evaluation is given below. Assume that a user enters 10 4 3 + 2 and program reponds with-4) 1032 43- 2 10 4 0 4 3 0 7 2 0 14 10-1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started