Show the postfix expressions

Assignment Help Data Structure & Algorithms
Reference no: EM13192086

An infix expression is one in which operators are located between their operands. This is how we are accustomed to writing expressions in standard mathematical notation. In postfix notation, the operator immediately follows its operands. Examples of infix expressions are:

One advantage of postfix is that unlike infix, no parentheses are necessary. Another advantage is that postfix expressions are easily evaluated using a stack.

This project will require you to create a Java program that will take an input file consisting of several lines of infix notation mathematical calculations, convert them to postfix notation (using the first algorithm in Part1), and evaluate them (using the second algorithm in Part2). The results of the calculations will then be printed to an output file. This project will build on your array and linked list implementations, using them to create your own implementations of stacks and queues for each of the algorithms.

This part will use both a stack and queue in order to convert expressions from infix to postfix notation.

The stack and queue will be implemented by you, using your linked list implementation from labs.

For this part, you will need to maintain two queues and one stack:

- A stack for conversion ‎ Infix to Postfix ‎ (Using Array Implementation)
- A queue for accumulation the digits of the operand (NumQueue) (Using Array Implementation)
- A queue to store the Postfix notation (PostQueue) (Using Linked list Implementation)

Each value will be read from the input line, and dealt with in the following manner:

1. When an operand is read, add it into( NumQueue)

2. When an operator is read

- Convert (NumQueue) into a single floating number, add it into(PostQueue) immediately

- Pop the stack elements and add them to the queue (PostQueue) one by one until the top of the stack has an element of lower precedence

- Then push it into stack.

- When a close-parenthesis [‘)'] is found, pop all the stack elements and add them to the queue (PostQueue) one by one until an open-parenthesis [‘(‘] is found

- When we reach the end of input, pop everything that remains on the stack and add to the queue (PostQueue) one by one.

- Notes : [‘)'] has the lowest precedence when in the stack but has the highest precedence when in the input

When finished converting one statement into a queue in postfix notation, pass the queue (PostQueue) to the next step - the postfix expression evaluator.

Reference no: EM13192086

Questions Cloud

Illustrate this in a vector diagram : A ship travels 200km west from port and then 240km due south before it is disabled. Illustrate this in a vector diagram. Usa trigonometry to find the course that a rescue ship must take from port in order to reach the disabled ship.
Depict the structure of the product that is formed : Draw the structure of the product that is formed when the compound shown below undergoes an elimination reaction with NaOCH3
Find the surface area of the pool : the length of a rectangular pool is 6 meters less than twice the width. if the pool's perimeter is 126 meters, find the surface area of the pool.
What is the variable cost of producing 40 units of output : (c) What is the variable cost of producing 40 units of output (d) How many units of the variable input should be used to maximize profits (e) What are your maximum profits (f) Over what range of variable input usage do increasing marginal returns exi..
Show the postfix expressions : An infix expression is one in which operators are located between their operands - Pop the stack elements and add them to the queue (PostQueue) one by one until the top of the stack has an element of lower precedence
Find the force against the end : A trough full of water has vertical ends in the shape of an isosceles triangle 5m across the top and 2m deep. Find the force against the end.
Compute the concentration in the units of molality : A solution is made witmlh 20.2ml of CH3OH ( density= 0.782g/ml), dissolved in 100.ml of water (density = 1.00 g/ml). Calculate the concentration in the units of:
How much will the fencing cost : A fence is being built to enclose a backyard. The yard is 150 ft wide by 325 ft long. The back of the house will act as on side of the fence. Fencing sells for 13.00 dollars per ft. How much will the fencing cost?
Calculate point price elasticity of demand for solis product : (b) What is the maximum total revenue per year that Solis can obtain from sales of its product (Give the exact dollar amount and show how you determined it.) (c) Calculate the point price elasticity of demand for Solis product when Q=50000. Is the..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Benefits of dynamic over static arrays

Discuss the benefits of dynamic over-static arrays. Under what conditions will you choose dynamic arrays?

  An algorithm that will sort a with a worst-case runtime

Let A be an array with n elements such that the first n -sqrt( n) elements are already sorted (though we know nothing about the remaining elements). Give an algorithm that will sort A with a worst-case runtime substantially better than O(n logn).

  C program to compute and display sales of a store

Modify the C program so that user inputs the buying amount. Check the user's input for validity.

  Explanation of oracle9i database

Take your current knowledge of Oracle Logs ect and project how a bank may make use of integrity control mechanisms.

  Write an algorithm to count nodes in a linked list

storage pool and that there is a special null value. Write an algorithm to count the nodes in a linked list with first node pointed to by first."

  Use sequential search algortithm to locate the number

These numbers should be stored in an array. Use the sequential search algortithm to locate the number entered by the user. If the number is in the array, the program should display a message.

  What is the machine run time in second for sorting array

Write computer program to implement this algorithm and demonstrate the results and what is the machine run time in second for sorting array A?

  Survey of fault tolerance policy for load balancing scheme o

This paper investigates about fault-tolerance in load balancing schemes in distributed environment. There are some more parameters influencing QOS but our main focus is on fault tolerance and load balancing.

  Divide-and-conquer two-dimensional closest-pair algorithm

consider the version of the divide-and-conquer two-dimensional closest-pair algorithm in which, instead of presorting input set P, we simply sort each of the two sets Pl and Pr in nondecreasing order of their y coordinates on each recursive call

  Setup an example rsa public/private key pair using primes

RSA with three primes would also work: n = pqr, ?(n) = (p?1)(q?1)(r?1), gcd(e, ?(n)) = 1, and d = e^?1 (mod ?(n)).

  You assign each int with a particular id

You assign each int with a particular ID.Array (4, 5, 6, 5, 4, 6) ID (1, 2, 3, 4, 5, 6)

  The radix sort algorithm

Show what happens to the radix sort algorithm if the counting sort is not a stable sorting algorithm. Bring a counter example

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd