Vertical order print question


error?

Vibhuti, you havent use the correct approach for building your tree, pls go through the BFS traversal in binary tree lecture of online course, use tht logic only to build your tree…Change this first and then still if u face any issue, you can send me the code again…

https://ide.codingblocks.com/s/162222,changed to bst still so many errors …kindly modify the code and tell why do we ahve to make bst and not normal binary tree

You have to use this approach for building the tree as,
node *buildtree_Level()
{
int d;
cin>>d;
node *root=new node(d);
queue<node *>q;
q.push(root);
while(!q.empty())
{
node *f=q.front();
q.pop();
int c1,c2;
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;
}

This approach is already explained in the BFS traversal videos given under binary trees…