Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i don't have any requriment pappers or anything. i have only this We commonly write arithmetic expressions in inftx form, that is, with each operator
i don't have any requriment pappers or anything. i have only this
We commonly write arithmetic expressions in inftx form, that is, with each operator placed between its operands, as in the following expression (3+ 4) (52) Although we are comfortable writing expressions in this form, infix form has the disadvantage that parentheses must be used to Indicate the order in which operators are to be evaluated. These parentheses, In turn, greatly complicate the evaluation process Evaluation is much easier if we can simply evaluate operators from left to right. Unfortunately, this evaluation strategy will not work with the inftx form of arithmetic expressions, However, it wil work If the expression is in postfx form. In the postftx form of an arithmetic expression, each operator is placed Immediately after its operands. The expression abowe is written in posthx form as 3 4 5 2/ Note that both forms place the numbers in the same order (reading from left to right), The order of the operators ts different, in the order that they are evaluated. The resulting postftix expression ls hard to read at first,but it is easy to evaluate All you need is a stadk however, because the operators in the postfix form are positioned l results have an artthmetic expression in postftx form that consists of a sequence of single digit, nonnegative integers and operators (addition, subtraction, multipli- cation, and division). This expression can be evaluated using the following algorithm in conjunction with a stack of floating-point numbers the following Read in the on character-by-character. As each character is read in: then If the character corresponds to one of the arithmetic operators (characters Pop a number off of the stack. Call it operand1 Pop a number off of the stack. Call it operand2. and
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