Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task - 1 : Write a java program using Stack to convert the infix notation to postfix. Your program will ask user to input the

Task-1:
Write a java program using Stack to convert the infix notation to postfix. Your program will ask
user to input the infix notation and will print out the equivalent postfix notation.
Following are the algorithmic steps to convert infix to postfix:
When an operand is read, it is immediately placed onto the output.
Operators and (are not immediately output, so they must be saved on to the stack.
If we see a ), then we pop the stack, writing symbols until we encounter a
(corresponding)(, which is popped but not output.
If we see any other symbol,+**,(, then we pop entries from the stack until we find an
entry of lower priority. One exception is that we never remove a (from the stack
except when processing a ). For the purposes of this operation, + has lowest priority
and ( highest.
When the popping is done, we push the operator onto the stack.
Finally, if we read the end of input, we pop the stack until it is empty, writing symbols
onto the output.
Note: You must use your own implementation of Stack (Array or LinkedList implementation).
Do not use the Java libraries (java.util.Stack)
image text in transcribed

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

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions