Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java code 7. Write a java program to implement the infix evaluation: 6+8/2-(2-2) + 5 (3Marks) Algorithm: Take two stacks: 1. operator stack {for operators

java code
image text in transcribed
7. Write a java program to implement the infix evaluation: 6+8/2-(2-2) + 5 (3Marks) Algorithm: Take two stacks: 1. operator stack {for operators and parentheses } 2. operand stack Algorithm f character exists to be read: 1. If character is operand push on the operand stack, if character is (push on the operator stack 2. Else if character is operator 1. While the top of the operator stack is not of smaller precedence than this character. 2. Pop operator from operator stack. 3. Pop two operands (op1 and op2 ) from operand stack. 4. Store opl op op2 on the operand stack back to 2.1. 3. Else if character is ). do the same as 2.2 - 2.4 till you encounter (. :lse (no more character left to read): Pop operators untill operator stack is not empty. Pop top 2 operands and push op op op on the operand stack. eturn the top value from operand stack

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

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions

Question

c. What were you expected to do when you grew up?

Answered: 1 week ago