Https://ide.codingblocks.com/s/268757

i see this program from geeks for geek but i dont ubnderstand howe line 8 is working basicall i dont understand how wwe are storing in vector by using map and how we are havingh output

hd is vertical column no
intially it is 0 as we go in left it decrease and towards right it increase

image

look at image
at end of traversal map looks like
-1 --> 25
-2 -->10
0 --> 50 ,40,60
1 --> 75
2 --> 90

in this way it is printing vertical order
i hope this helps

bhaiya i dont understand how to tale leve; order input

you have to use the same way as used in level order Traversal
use this

node* build() {
    int d;
    cin>>d;
    node*root=new node(d);
    queue<node*> q;
    q.push(root);

    int x;
    while(!q.empty()) {
        node* f=q.front();
        q.pop();

        cin>>x;
        if(x!=-1) {
            node*n=new node(x);
            f->left=n;
            q.push(n);
        }

        cin>>x;
        if(x!=-1) {
            node*n=new node(x);
            f->right=n;
            q.push(n);
        }
    }

    return root;
}

use the same way as done in Level Order Traversal

node* build() {
    int d;
    cin>>d;
    node*root=new node(d);
    queue<node*> q;
    q.push(root);

    int x;
    while(!q.empty()) {
        node* f=q.front();
        q.pop();

        cin>>x;
        if(x!=-1) {
            node*n=new node(x);
            f->left=n;
            q.push(n);
        }

        cin>>x;
        if(x!=-1) {
            node*n=new node(x);
            f->right=n;
            q.push(n);
        }
    }

    return root;
}

i hope this clear now
if yes hit a like and don’t forgot to mark doubt as resolved :grinning:
if you have more doubts regarding this feel free to ask