Purchase Solution

Infix to Postfix Expression conversion using C++

Not what you're looking for?

Ask Custom Question

My goal is to implement a C++ program that converts an infix expression into a postfix expression and then evaluates the postfix expression. I am using the Stack and Queue classes I developed with a List class (linked list) that manages the data in the stack and queue.

The output will be: Print out the infix expression, the postfix expression, and the calculated results of the expression.

I have to be able to handle the ( ) + - * / and ^ (exponential/power) operators. The precedence of ^ operator is higher than that of * and / operators.

I have attached the algorithm I am using to do this as well as the input to read in and use.

Read in the data 1 token at a time and deal with it then, do not read anything in as a string.

This must be implemented within my program and must use the stack and queue and general list I already have.

Purchase this Solution

Solution Summary

This solution is an extension to the work provided by the student in the question. Kindly use it as a guidance to develop your own solution, in case you plan to use it somewhere. Also note that GNU C++ compiler g++ version 4.3.4 was used during development of solution program.

Solution Preview

Please note that following input in your infix.txt has problem - incorrect input in the part "...*(/4)...".


Since the existing implementation returns NULL (0) value when you get the top value of an empty stack, due to which above incorrect arithmetic expression gets evaluated to an incorrect value.

Attached program has been ...

Purchase this Solution

Free BrainMass Quizzes
Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.