OK, here's a cut down version of your tree that just inserts and does an InOrderTransversal (the other traversal functions can be done in the same manner) -
Code:
#include<iostream>
#include<iomanip>
#include<fstream>
#include <cctype> // defines isalpha() function
using namespace std;
struct node
{
int key_value;
node *left;
node *right;
};
class btree
{
public:
btree();
void insert(int key);
void InOrderTranverse();
private:
void insert(int key, node *leaf);
void InOrderTranverse(node *leaf);
node *root;
};
int main()
{
btree bt;
int num=0;
char chr;
cin>>num;
cin>>chr;
while(cin)
{
bt.insert(num);
cout << "InOrderTranverse: ";
bt.InOrderTranverse();
cout << endl;
cout<<"Step: "<<count<<" "<<"Data Value = "<<num<<" "<<"Activity Signal = "<<chr<<endl;
cin>>num;
cin>>chr;
}
return 0;
}
//Constructor
///////////////////////////////////////////////////////////////////////
btree::btree()
{
root=NULL;
}
//Insert Tree
//////////////////////////////////////////////////////////////////////
void btree::insert(int key, node *leaf)
{
if(key< leaf->key_value)
{
if(leaf->left!=NULL)
insert(key, leaf->left);
else
{
leaf->left=new node;
leaf->left->key_value=key;
leaf->left->left=NULL; //Sets the left child of the child node to null
leaf->left->right=NULL; //Sets the right child of the child node to null
}
}
else if(key>=leaf->key_value)
{
if(leaf->right!=NULL)
insert(key, leaf->right);
else
{
leaf->right=new node;
leaf->right->key_value=key;
leaf->right->left=NULL; //Sets the left child of the child node to null
leaf->right->right=NULL; //Sets the right child of the child node to null
}
}
}
///////////////////////////////////////////////////////////////////////
void btree::insert(int key)
{
if(root!=NULL)
insert(key, root);
else
{
root=new node;
root->key_value=key;
root->left=NULL;
root->right=NULL;
}
}
//////////////////////////////////////////////////////////////////////
void btree::InOrderTranverse(node *leaf)
{
if(leaf->left != NULL)
InOrderTranverse(leaf->left);
cout<<leaf->key_value<< " ";
if(leaf->right !=NULL)
InOrderTranverse(leaf->right);
}
//////////////////////////////////////////////////////////////////////
void btree::InOrderTranverse()
{
if(root!=NULL)
InOrderTranverse(root);
else
return;
}
If you are unsure on anything post a reply instead of waiting a few days and then reposting the same question again.