Hello, i have a problem with inserting an expression on the tree. I have to do a program that puts logical expressions for example: AND AND OR T F T F. I have no idea how to solve it. My current code performs the functions of calculating the value of trees and printing the expression in the tree. Below is my current code of function insertnode, but it is not working properly. Please help me with the problem. Thanks in advance.
[CODE]void insertnode(tree *&root, char newitem, bool operator)
//the parametr operator valuse:1-operator, 0-operand
{
if(root==NULL)
{
root=new tree(newitem);
root->typ=operator;
return;
}
if(root->left!=NULL)
{
if(root->left->typ)
insertnode(root->left,newitem,operator);
}
if(root->right!=NULL)
{
if(root->right->typ)
insertnode(root->right,newitem,operator);
}
if(root->left==NULL)
insertnode(root->left,newitem,operator);
else if(root->right==NULL)
insertnode(root->right,newitem,operator);
}[/CODE]