Identical Binary Search Trees?

Given two binary trees, return true if they are structurally identical — they are made of nodes with the same values arranged in the same way.

Check for each data with the corresponding data in the other tree, return true if the check never fails.

bool identical(struct tnode* a, struct tnode* b){
if (a==NULL && b==NULL){
}else if (a!=NULL && b!=NULL){
return(a->data == b->data && identical(a->left, b->left) &&
identical(a->right, b->right));

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: