Question: Given two binary trees, write a compare function to check if they are equal or not. Being equal means that they have the same value and same structure.

Solution: The following is a function to check if the two trees are similar or not.It returns true if they are similar else false.
int compareTree(struct node* a, struct node* b) {
if (a==NULL && b==NULL)
return(true);
else if (a!=NULL && b!=NULL) {
return(
a->data == b->data &&
compareTree(a->left, b->left) &&
compareTree(a->right, b->right)
);
}
else return(false);
}