Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books