subject

Postfix evaluation In this assignment, you are to input an infix expression, convert it to
postfix (see the previous assignment - Posted below) and then evaluate it. You should
use a generic stack(i. e. a templated stack). Note: Ignore blank lines.
Input for the assignment:
2 + 3 * 5
2 + 3 * 5 ^ 6
2 + 3 - 5 + 6 - 4 + 2 - 1
2 + 3 * (5 - 6) - 4
2 * 3 ^ 5 * 6 - 4
(2 + 3) * 6 ^ 2
Sample output
1: 2 + 3 * 5
235*+
17
2: 2 + 3 * 5 ^ 6
2356^*+
46877
3: 2 + 3 - 5 + 6 - 4 + 2 - 1
23+5-6+4-2+1-
3
4: 2 + 3 * (5 - 6) - 4
2356-*+4-
-5
5: 2 * 3 ^ 5 * 6 - 4
235^*6*4-
2912
6: (2 + 3) * 6 ^ 2
23+62^*
180
You might also try:
7: ( ( ( ( 2 + 3 - 4 ) / 2 + 8 ) * 3 * ( 4 + 5 ) / 2 / 3 + 9 ) )
23+4-2/8+3*45+*2/3/9+
45
The Evaluation algorithm is as follows:
st = postfix_string
for (i=0; i < length(st); i++)
{
token = st[i]
switch (token)
{
digit :
push token
break

operator :
pop opn2
pop opn1
result = evaluate(opn1, token, opn2)
push result
break
}
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 09:50
What is a rush associated with alcohol?
Answers: 1
question
Computers and Technology, 24.06.2019 00:00
Afashion designer wants to increase awareness about her brand. which network can she use and why she can use the blank to blank her products online. answers for the first blank: internet, extranet, or intranet answers for the second blank: market, design, and export
Answers: 1
question
Computers and Technology, 24.06.2019 10:00
When writing a business letter, how many times can you use the same merge field in a document? once once, unless using the address block feature unlimited it will depend on the type of document you choose
Answers: 1
question
Computers and Technology, 24.06.2019 17:40
Which of the following processes applications across multiple computing devices? a. functional application b. distributed system c. workgroup information silo d. information silo
Answers: 3
You know the right answer?
Postfix evaluation In this assignment, you are to input an infix expression, convert it to
po...
Questions
question
Biology, 06.10.2019 06:00
Questions on the website: 13722359