Assignment (10)
CS3430 - Due Tuesday March 22 (9:59 pm)
Create a directory assgn10 under 3460 and keep all your files in that directory.

You will write a program to display an expression in three different ways.  In order to do this, you need to first create the Expression Tree that holds the expression. The process is explained in Section 4.2.2 of the textbook.  We will go through a couple of examples in class.  You should be able to modify the linked list version of the Binary Search Programs ( BinarySearchTree.cpp, BinarySearchTree.h ,TestBinarySearchTree.cpp) for most of what you need to do in this assignment.  Your program should include two classes, as it is the case with the above Binary Search Tree program.  To see how the above program works, copy all these files into your directory and compile the TestBinarySearchTree.cpp file, then run it.   Note that you can  include the stack from the STDL using (#include<stack>) or you can use the stack.h file from the textbook as (#include "stack.h" ). In this case, you also need to have the stack.cpp in your directory.  It is best to use the standard stack.

The description of these two classes are given below.  You MUST follow this description to receive full credit for your program.

Description of the classes you need

The BinaryTree Class

Create a Template Binary Tree class (named BTree) with the following public member functions:
private functions
private variables

The BinaryNode class

Create a Template Binary tree Node class (named BinaryNode) with the following public member functions
private variables
Make Binaryree a friend class so it can access the internals of a BinaryNode

The Program

Write a program that implements the Expression Tree construction algorithm illustrated in 4.2.2 of the textbook. Use the stack standard template library class. The stack standard template library class is described at Quick Intro to the stack STL Container Adapter

I/O Requirements

The expression will read a string of character from a file in postfix expression form. You can assume that variables are single characters and only binary operations (+, -, /, *, ^) will be used. After storing the expression as a tree, your program should display the expression in prefix, postfix, and infix forms.

Here is an example of an input file:
a b +

Example of a run:

./a.out   input.txt
InFix expression: (a+b)
PreFix expression:  +ab
PostFix expression: ab+


Leave all your files in directory 3460/assgn10 and do not make any change after 9:59 pm on the due date.  I will copy all your files by 10:00 pm that date.