Discuss infix to postfix conversion

Assignment Help Data Structure & Algorithms
Reference no: EM13326220

Part 1:

Infix to Postfix conversion

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.

Part 2: : Evaluating the postfix expression

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

- A stack Evaluating the postfix expression ‎ (Using Linked list Implementation)

This step will use the queue (PostQueue) that was the result of the infix to postfix conversion, and a stack. The algorithm proceeds as follows:

1. Make an empty stack (Using Linked list Implementation)

2. Scan the postfix expression (PostQueue) one item at a time:

- If it is an operand, push onto the stack.
- If it is an operator,
- pop two numbers from the stack,
- apply the operator, and
- push the result back onto the stack.
- If the stack does not have enough operands, the expression is invalid.
- At the end of input, check the stack. If it has just one item, that is the answer. Else, the expression is invalid.

Reference no: EM13326220

Questions Cloud

Calculate the resulting charge on each capacitor : Capacitors C1 = 6.10 µF and C2 = 2.95 µF are charged as a parallel combination across a 250 V battery. Calculate the resulting charge on each capacitor
What is the value of the resistance : A heart pacemaker fires 66 times a minute, each time a 29.0-nF capacitor is charged (by a battery in series with a resistor) to 0.632 of its full voltage
What is the current after one time constant : A 495-? resistor, an uncharged 1.50-µF capacitor, and a battery with an emf of 6.21 V are connected in series. What is the current after one time constant
Hr risk management strategy plan succession plan : HR risk management strategy plan succession plan: outline a training and development program to cross-train for key positions, assess the training and development programs for ease of implementation
Discuss infix to postfix conversion : This part will use both a stack and queue in order to convert expressions from infix to postfix notation.
Explain the economic loss doctrine-transport corporation : Explain “the economic loss doctrine.” Explain how it applies to AOL. Explain how it applies to Transport Corporation. Explain what AOL could have done to better protect itself in the process of making an insurance deal. Lecture on economic loss doctr..
What are the charge on each electrode : Two 11-cm-diameter electrodes 0.54cm apart form a parallel-plate capacitor. What are the charge on each electrode, the electric field strength inside the capacitor
Parenting practices over generations : How were the parenting practices similar and different between generations and identify and explain contextual factors (other than cohort effects) described by Kotchick and Forehand (2002) that might have influenced the parenting practices of each ..
Determine the maximum displacement of the plate a : A 23-lb crate is pushed by a force F, which has the magnitude that varies as shown on the graph. If the crate is originally at rest and it takes 3 seconds after applying the force to hit the bumper

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Explaining view of header and footer areas of worksheet

In which view can you see header and footer areas of worksheet?

  Question about trigger

What are triggers used for, and why are they important in database systems? Give an example of a situation where a trigger would be appropriate.

  Algorithm to read arbitrary number of data records

Write the algorithm to read arbitrary number of data records, each comprising name, age, and code.

  Design algorithm determining annual profit for company

Your goal is to solve the following simple programming exercise. You have been asked by your accounting department to design an algorithm determining the annual profit for your company.

  Implement a nice graph datastructure

Implement a nice graph datastructure. Implement two different greedy graph coloring algorithms. Shortest path algorithm and MST algorithms.

  Singly linked list

Singly Linked List (SLL)Introduce a SLL class with the following functions. Please also introduce a main function that will invoke and verify whether the functions are implemented correctly

  Calculate worst-case run-time complexity of algorithm

Calculate the worst-case run-time complexity of your algorithm and prove optimality of the solution it gives. Suppose that the road is a straight line with a western end and an eastern end.

  Program development cycle for algorithm using pseudocode

Illustrate all your work. Use modular approach to solving this problem. Give the following submodule. Calculations - module to compute gross pay. Using the Program Development Cycle, develop an algorithm using pseudocode for the following task.

  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)

  Algorithm for partitioning a set of n weights into k

give a greedy algorithm for partitioning a set of n weights into k bins. b) does it find the perfect solution?

  Write algorithm which divides n objects of u into k clusters

Suggest the algorithm which divides n objects of U into k clusters, making use of MST of a graph. Give a simple argument of correctness and bound on the running time of the algorithm you are proposing.

  Explain an application level protocol

Create and explain an application level protocol to be used in an automatic teller machine and a bank's centralized computer. Your protocol should permit a user's card and password to be verified,

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