please help to solve and send the corrected code
Please tell why my code is not working
The approach you are using in your buildtree function is wrong…you need to build the tree by using level order traversal with the help of queues.
node *buildtreeLevel()
{
queue<node *>q;
int d;
cin>>d;
node *root=new node(d);
q.push(root);
int c1,c2;
while(!q.empty())
{
node *f=q.front();
q.pop();
cin>>c1>>c2;
if(c1!=-1)
{
f->left=new node(c1);
q.push(f->left);
}
if(c2!=-1)
{
f->right=new node(c2);
q.push(f->right);
}
}
return root;
}