Regarding Tree Left view

How to construct the tree from level order traversal

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

    while(!q.empty())
    {
        cin>>a;
        if(a!=-1)
        {
            node *temp = new node(a);
            if(q.front()->left==NULL)
            q.front()->left = temp;
            else
            {
                q.front()->right = temp;
                q.pop();
            }
            q.push(temp);
        }
        else
        {
            if(q.front()->left==NULL)
            {
                cin>>a;
                if(a==-1)
                    q.pop();
                else
                {
                    node *temp1=new node(a);
                    q.front()->right = temp1;
                    q.pop();
                    q.push(temp1);
                }
            }
            else
                q.pop();
        }
    }
    return root;
}

Just call this function

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.