Stack evaluating the postfix expression

Assignment Help Data Structure & Algorithms
Reference no: EM13192112

 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.

Consider Postfix the expression 2 3 4 + 9 * 1 - +

43_Stack Evaluating the postfix expression.png


Input file:

The input file will contain several lines of equations in infix format. Each line can use several of the available mathematical: addition [+], subtraction [-], multiplication [*],division [/], parentheses and

Output file:

For each calculation, print the following to the output file

- The postfix notation (the result from Part1 )

- The result of the calculation (the result from Part2 )

1307_Stack Evaluating the postfix expression1.png

Reference no: EM13192112

Questions Cloud

Attractions and entertainment places-growing popularity : Give some of the main reasons that attractions and entertainment places are enjoying growing popularity.
Define sample of solid ammonium nitrate dissolves : When a 4.25-g sample of solid ammonium nitrate dissolves in 60.0g of water in a coffee-cup calorimeter, the temperature drops from 22.0 degree C to 16.9 degree C.
Write a polynomial to represent the volume of the box : marcy uses a sheet of 8 inch by 11 inch paper to make an open box. She cut x by x squares out of each corner, and folded up the sides. The diagram below shows the finished box.Simplify your expressions and justify your answer to each of the questi..
Effects of playing soft music during an exam : Three researchers wish to test the effects of playing soft music during an exam on the test performance of their sociology students. They conduct an experiment in which one test-taking class hears music and another does not.
Stack evaluating the postfix expression : Step will use the queue (PostQueue) that was the result of the infix to postfix conversion, and a stack -  A stack Evaluating the postfix expression
Find the dimensions of the paper that will produce a tube : A rectangular piece of paper with perimeter 100cm is to be rolled to form a cylinder. Find the dimensions of the paper that will produce a tube with maximum volume.
Calculate the new equilibrium level of income : Given the following variables in the open economy aggregate expenditure model, autonomous consumption (C o) = 200, autonomous investment (I o) = 200, government spending (G o) = 100, export spending (X o) = 100, autonomous import spending (M o) = ..
State what is the maximum number of grams : what is the maximum number of grams of [Co(NH3)6]Cl3 that can be produced?
What is projected average out-of-pocket costs for benefits : What is the projected average out-of-pocket costs for beneficiaries in 2010

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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