Binary trees trouble

First of all this is an assignment, i am in my second year in Computer Science and this assignment is due on midnight which is 6 hours more or less.i know i am not supposed to ask 4 help with assignments but i really need help !:(
the assignment is basically a binary tree that reads a prefix expression and prints it out in inorder expression. the problem is with the function that constructs the tree, it doesnt read the entire expression and when i tried putting a while loop that ends with the end of the expression it gives me errors that the the root or left child is full. this is my function , if anyone has anyinput on what i am supposed to do please share.. i will be very grateful!

void BuildTree (bintree *T) // function to build tree
{
bintree* Cur;
static int i=0;
if(!T) //errror in creating tree
cout<<"Memory allocation error!"<<endl;
else //tree created
{

if(Exp[i]=='+'|| Exp[i]=='-'|| Exp[i]=='*' ||Exp[i]=='/') //if
//input is operator insert in root

{
T->InsertRoot(Exp[i]);
i++;
T->InsertLeft(Exp[i]); //Insert the next
//element in the left child

if(Exp[i]=='+'|| Exp[i]=='-'|| Exp[i]=='*' ||Exp[i]=='/') //if the next element is an operator then the element
// following should be in the left child

{
Cur=T->RetrieveLeft(); // retrieves the
//pointer pointing to the left child
i++;
Cur->InsertLeft(Exp[i]); //inserts the
//next element in the left of the Primary left child

}

else // if the next element is an operand then
//the element should be in the right child
{
Cur=T->RetrieveParent(); //retrieves
//the pointer pointing to the parent or the root
i++;
Cur->InsertRight(Exp[i]); //inserts the
// next element in the right child of the parent or root
}
}
else cout<<"A prefix expression must begin with an operator"<<endl;
}
}
in my program i have a class and cpp for the binary trees but it works just fine. any thoughts?
Your Function calling is not right .....

void BuildTree (bintree *T) // function to build tree

you are using struct or class and this is not the right wats to call ( :: ) is missing ....
Topic archived. No new replies allowed.