Identical-Binarytree


showing wrong answers.why?

@rajukumarbhui You are missing some cases.Also you do not need to compare data values as in this problem you just need to find if it is structurally identical.

Your function should be something like this:

bool isSame(node* root1,node* root2){
if(root1 == NULL && root2 ==NULL){
return true;
}
if(root1==NULL && root2 != NULL){
return false;
}
if(root1 != NULL && root2 == NULL){
return false;
}

if(root1->data == root2->data){
return (isSame(root1->left,root2->left) && isSame(root1->right,root2->right));
}
else{
return false;
}

Hope this helps :slightly_smiling_face: