How to take input for this code can i have a boiler plate code for this of how to take input

for level order zigag

Suppose there are value 10 true 20 ,basically false represents that child is NULL and value represent the value of child ,take input as string and use recursion to build the tree,dry run the code that I have sent ,when string is false we attach NULL and when string is true we have build tree using recursion.

node*buildtree()
{
    string str;
    cin>>str;
    if(str=="false")
    {
           return NULL;
    }
    if(str=="true")
    {
         string d;
         cin>>d;
         node*root=new node(d);
        root->left=buildtree();
        root->right=buildtree();
        return root;
    }
    node*root=new node(str);
        root->left=buildtree();
        root->right=buildtree();
       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.