I am unable to understand the input format for this problem .
in the given sample test case we have n = 4, which makes (2^n)-1 elements which is 15 for it but the input is for 19 elements ??
Vertical order print for a binary tree
vertical order traversal kind of input is given when -1 is encountered that means that node there are no further nodes to it.
the build function would look something like this:
node* buildTreeLevelWise(){
int d;
cin>>d;noderoot = 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;
}