Doubt in the input format

Sir, I am getting confused in in the input format.
Can you tell me how to take the input?

hello @vageesha

u have to do level order traversal for taking input.

refer this->

node* BuildTree() {
    int d;
    cin >> d;
    if (d == -1)return NULL;
    node* root = new node(d);
    queue<node*>q;
    q.push(root);
    while (!q.empty()) {
        node* temp = q.front();
        q.pop();
        int lc, rc;
        cin >> lc >> rc;
        if (lc != -1) {
            temp->left = new node(lc);
            q.push(temp->left);
        }
        if (rc != -1) {
            temp->right = new node(rc);
            q.push(temp->right);
        }
    }
    return root;
} 

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.