Implement algorithm for evaluation of arithmetic expression

Assignment Help Data Structure & Algorithms
Reference no: EM1358023

Implement the following algorithm for the evaluation of arithmetic expressions. Each operator has a precedence. The + and - operators have the lowest precedence, * and / have higher (and equal) precedence, and ^ (which denotes "raising to a power" in this excercise) has the highest. For example,

3 * 4 ^ 2 + 5

should mean the same thing as

(3 * (4 ^ 2)) + 5

with a value of 53.

in your algorithm, use two stacks. One stack holds numbers, the other holds operators. When you encounter a number, push it on the number stack. When you encounter an operator, push it on the operator stack if it has higher precedence than the operator on top of the stack. Otherwise, pop an operator off the operator stack, pop two numbers off the number stack, and push the result of the computation on the number stack. Repeat until the top of the operator stack has lower precedence. At the end of the expression, clear the stack in the same way.

Reference no: EM1358023

Questions Cloud

Physical units-nrv-constant : Bubble Corporation manufactures two products, I and II, from a joint process. A single production costs $4,000 and results in 100 units of I and 400 units of II. To be ready for sale, both products must be processed further, incurring separable co..
Verbally aggressive schizophrenic client : Sometimes I am able to, and at other times I can't even get him to listen to me. Do you have any suggestions on how I can help him when he has those episodes?
Compute the confidence intervals for the expected annual : Using the following table, compute the 95% confidence intervals for the expected annual return of the four different investments.
Enticing non-union organizations to unionize : Explain what are the various methods utilized by staff representatives to woo the employees of non-union organizations to unionize?
Implement algorithm for evaluation of arithmetic expression : Implement the following algorithm for the evaluation of arithmetic expressions. Each operator has a precedence. The + and - operators have the lowest precedence.
Find the eight balls speed after the colision : Find the eight ball's speed after the colision. Parallel rays of green mercury light with a wavelength of 546 nm pass through a slit with a width of 0.437 mm. What is distance from the central maximum to the first minimum on a screen 1.75 mm away f..
Determine the equilibrium market value : Jason Corporation had after-tax income of $15,000 with 10,000 stock shares outstanding. The 2 owners are trying to determine the equilibrium market value for the stock prior to going public.
Recruitment and retention-hiring strategies : Recruitment and Retention: Hiring Strategies - The original case study
What is the market value of this patent : Assume a firm has a patent on one of its products whose sale generates $32,700/year more revenue than production costs. If the annual interest rate is 20 percent, what is the market value of this patent.

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