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

  Spreadsheet to compute projected total costs and profits

Prepare a spreadsheet to compute your projected total costs, total revenues, and total profits for giving seminar on cost estimating.

  Algorithm to divide sixteen digit value by six digit integer

Divide 16 digit value N by six digit integer D obtaining quotient Q and remainder (or sign of the remainder) R by division algorithms.

  Solving information technology question

XYZ Corporation has a small office with eighty users in California. The office employs a file and print server that caters to user requests.

  Create a program using c++

Create a program using C++ or Java that will automatically generate x numbers between a range provided by the user? For purposes of this project, the range can be 1-20 and store them in an array.

  Finding median by black-box worst-case linear-time algorithm

Given a black-box worst-case linear-time algorithm for ?nding median, create algorithm solving the selection problem for an arbitrary order statistic.

  Discuss and define complex data binding

Discuss and define complex data binding and what benefits can this capability lend to a multiple table database application?

  Linear-time algorithm for computing the strong component

On the basis of a linear-time algorithm for computing the strong component containing a given vertex v, describe a simple quadratic-time algorithm for computing the strong components of a digraph.

  Question about hardware requirements

When you purchase a new software package, why does it state minimum RAM and hard drive space your computer must have for you to run this program?

  Database design process

A college course may have one or more scheduled sections, or may not have a scheduled section. Attributes of COURSE include Course_ID, Course_Name, and Units.

  Write efficient pseudocode algorithm to determine record

Write the most efficient pseudocode algorithm you can to determine the record with specific customerID if every single customer ID from 101 to 500 is used and array has 400 elements.

  Determine how long the specific algorithms take

Some problems can be theoretically solved (we can explain the algorithm solving problem). How long does the specific algorithms take?

  Compiler to separate the numbers using dashes

write this code using structures.with writing the SSN in one line this ask the compiler to seperate the numbers using dashes.

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