Binary tree input in given format

Enter the values of all the nodes in the binary tree in pre-order format where true suggest the node exists and false suggests it is NULL

how to take this type of input e.g

10 true 20 true 40 false false true 50 false false true 30 true 60 false false true 73 false false

You can take an integer and a string, and initialise a variable x=0, and then check
if ( x==0)
then
root=new node(k);
root->left=buildtree(root->left);
root->right=buildtree(root->right);
else
you will take a string str, and check if its true, then
node *temp=new node(d);
temp->left=buildtree(temp->left);
temp->right=buildtree(temp->right);
else
for false, you will simply return root.

i am not able to understand this problem can you please provide me the solution of tree challenges question 1

I cannot send you the complete code, but can tell you the approach you can follow, can you plz tell in which part you need the approach, like on how you have to build the tree or the function where u need to check if the trees are identical or not. Plz reply so that I could help you accordingly.

I am also stuck in taking this kind of input from the user. Need help in writing code.

Try to write the code on your own, I will help you since i cannot give you the complete code… try first and then if you are not able to do it, I wll help you.

node* createTree(){
	int d;
	string ch;
	cin>>d;
	cin>>ch;

	if(ch=="true"){
		node *root=new node(d);
		root->left=createTree();
		cin>>ch;
		if(ch=="true"){
			node *root=new node(d);
			root->right=createTree();
		}
	}
	
	else if(ch=="false"){
		cin>>ch;
		if(ch=="true"){
			node *root=new node(d);
			root->right=createTree();
		}
		return root;
	}

}

here is the createTree() func that i was trying.

Swarnika, you can refer to this code for building your tree, if you didnt understood anything in the code, let me know,