The infix to postfix conversion

Assignment Help Data Structure & Algorithms
Reference no: EM132109195

For programming we are going to work with infix to postfix conversion. The starting point for the assignment is the infix to postfix conversion program provided by the textbook (program 7-3).

A code blocks project with all the associated header files for this program is uploaded on canvas for your starting point. As provided the program issues two warnings and the error and exception handling does not work.

The warnings are minor and do not cause a problem. Do not worry about the exception handling at this point. We are going to cover exception later in the course.

If you input an invalid expression the program will lock up. You can just restart if that happens. At first run the program with the examples to see how the program functions.

The main task of the assignment is to write your own stack class and use your stack to replace the stack from the standard library used by program 7-3.

Program 7-3 uses the standard library stack in two places d_rpn.h and d_inftop.h. Your stack must use a dynamically allocated array that grows as neededto store stack the items. We covered how to do this in class with the miniVector class.

The miniVector class is included with the material for the assignment. Your stack will also need to have functions top, push, pop, size and empty. These are the functions required by program 7-3.

Your stack should also include a destructor to release the dynamically allocated memory at the programs completion. Hint: if you use a template class you only have to implement a single stack class for this assignment. Test your stack by pushing 0 through 9 on to the stack. Then use top to read the top value and pop to remove all elements from the stack. If your stack is working correctly you should get 9 through 0 out.

After removing all ten items from the stack the empty function should return true. Include this output in your report to show that your stack is working.

Next, use your to stack to replace stack used in d_rpn.h and d_inftop.h. You can simply add another header file with your stack class to the provided code blocks project. Be sure to add #includes to your stack in the correct places so that the compiler can find your stack class.

If everything is working correctly program 7-3 will operate just as it did before. Run the program with sample test data and include this output in your report.

As implemented program 7-3 only does integer math. So if you input 1/2 the value returned is 0. Modify the postfixEval class found in d_rpn.h so that it returns a double value.

Hint: the remainder operator is not defined for double math and is no longer needed. Remove the remainder operator from the list of operators. One way to implement the double math is to add another header file to the project for double math.

Copy postfixEval into that new header file. It is okay two have two postfixEval versions in different header files. The version that the compiler will use is determined by the include directive in the main program.

Modify the postfixEval class in the new header file to do double math. Rerun the sample test data and include the output in your report.

Sample Test Data:

22

8-3*2

7+(4-6)*(8+6)/3

4+1+(2-1)

3/8+4*5

9*2+((4-3)*2)/2

Reference no: EM132109195

Questions Cloud

Display how many of each denomination would be needed : Write a C++ program that prompts the user for a cash value and an amount of purchases made against that amount.
Compute the acceleration of gravity for a given distance : Compute the acceleration of gravity for a given distance from the earth's center, dist_center, assigning the result to accel_gravity.
Develop using android studio a rent a car app : HC2051 - design and develop using Android studio a Rent a Car App, that provides a listing of six Australian known car rental companies. By selecting a car
Write a function that outputs everything in the order : Write a function that outputs everything in the order along with the total price. Write a suitable test program that adds multiple pizzas to an order(s).
The infix to postfix conversion : Modify the postfixEval class in the new header file to do double math. Rerun the sample test data and include the output in your report.
Design a program with loop that let the user enter a series : Design a program with loop that let the user enter a series of numbers. Compare each number to the current maximum and minimum.
Write a java program that will ask the user : Write a Java program that will ask the user to enter three integer numbers and find the greatest or the smallest of these numbers.
Create the logic for a program that performs functions : Create the logic for the methods sum() and difference(); they compute the sum of and difference between the values of two arguments, respectively.
Differences in the way the process is performed : ACC203 – Accounting Information Systems - What are the major differences in the way the process is performed - Explain how this case demonstrates

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