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

  Write a breadth-?rst search algorithm

Write an algorithm to classify the edges of a directed graph G into the four categories: tree edge, back edge, forward edge and cross edge (de?ned in De?nition 7.14, pages 342-343).

  Find terminal nodes in tree nil if pointer is represented

The node's right child. If the nil pointer is represented by 00 and the tree's root pointer contains 53, how many terminal nodes are in tree?

  Give algorithm to find schedule to obtain maximum profit

Give an algorithm to find the schedule that obtains the maximum amount of profit, assuming that all processing times are integers between 1 and n.

  Creating a home inventory database

Construct one query of your selection. Remember a query answers a question. As an example, list all household electronics that are greater in value than $200.

  Write algorithm for graph minimum number of semesters

You are given a DAG called G which is the prerequisite graph for a set of courses required for a degree. Each vertex corresponds to course. Provide a high-level description of algorithm which labels each vertex in G with minimum number of semesters..

  Create algorithm which generates access control matrix

Create an algorithm which generates the access control matrix A for any given history matrix H of the Chinese Wall model.

  Find the checksum field in a single parity bit scheme

Assume that the information content of a packet is the bit pattern 1111000010100101 and an even parity is being used

  Create a flowchart that programs a robot to recognize

Create a flowchart that programs a robot to recognize how many playing cards you have and to put them in order from smallest to largest

  Describe algorithm that finds maximum feasible flow in graph

Describe an algorithm that finds a maximum feasible flow in G. Denote by MF(|V|, |E|) the worst-case running time of an ordinary maximum flow algorithm.

  Design and implement an avl tree algorithm

Design and implement an AVL tree algorithm that searches a collection of documents. You will be provided with a set of 50 documents and a set of sample queries. First, you will process the documents and store their content (i.e. words / tokens) in..

  Program for stack by using dynamically allocated array

Write a C++ class which implements stack by using a dynamically allocated array. Initial size of particular stack must be determined when it is created.

  Find running time of heap sort input sorted-ascending order

Determine the running time of Heap Sort if input is sorted in ascending order. Determine the running time of Heap Sort if input is sorted in descending order.

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