Hi all,

I am working on a Binary Search Tree but cant seem to get it to run. Evrything I run the code i does some funny stuff that i dont understand. Please would someone help sort out the problem. thanks for any help

Code:

#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
struct tree_node
{
int data;
int menu;
tree_node* left;
tree_node* right;
};
tree_node * insert(tree_node *, int);
//void tree();
void in_order(tree_node *tree);
void ass_order(tree_node *tree);
void desc_order(tree_node *tree);
tree_node* insert(tree_node * tree, int element)
{
if(tree==NULL)
{
tree = new tree_node;
tree->left=tree->right=NULL;
tree->data=element;
}
else if(element < tree->data)
{
tree->left=insert(tree->left,element);
}
else
tree->right=insert(tree->right,element);
return(tree);
}
void in_order(tree_node *tree)
{
if(tree!=NULL)
{
cout<<tree->data;
in_order(tree->left);
in_order(tree->right);
getch();
}
}
void ass_order(tree_node *tree)
{
if(tree!=NULL)
{
ass_order(tree->left);
cout<<tree->data;
ass_order(tree->right);
getch();
}
}
void desc_order(tree_node *tree)
{
if(tree!=NULL)
{
desc_order(tree->right);
cout<<tree->data;
desc_order(tree->left);
getch();
}
}
menu()
{
tree_node * tree;
tree=NULL;
int choice, element;
do{
cout<< "======== Main Menu ========\n";
cout<<"1.Enter Number for the tree.\n";
cout<<"2.Numbers in inputed order.\n";
cout<<"3.Numbers in ascending order.\n";
cout<<"3.Numbers in descending order.\n";
cout<<"4.Exit.\n";
cout<<"\nPlease make a choice: ";
cin>>choice;
} while(choice!=1);
switch(choice) //used to get the choice form the user.
{
case 1: //promts the user to put a number into the tree
cout<<"\nEnter a number to add to the tree:";
cin>>element;
tree = insert(tree,element);
case 2: //prnits numbers in order inputed
cout<<"\nInput Order: ";
in_order(tree);
case 3: //prnits numbers in ascending order
cout<<"\nAscending Order: ";
ass_order(tree);
case 4: //prnits numbers in descending order
cout<<"\nDescending Order: ";
desc_order(tree);
}
} return main;