Wednesday, August 15, 2007

Write C code to determine if two trees are identical .

Here is a C program using recursion


int identical(struct node* a, struct node* b)
{
if (a==NULL && b==NULL){return(true);}
else if (a!=NULL && b!=NULL)
{
return(a->data == b->data &&
identical(a->left, b->left) &&
identical(a->right, b->right));
}
else return(false);
}

2 comments:

sandeep kumar said...

Thanks for the info.
Regards
Educational site

Anonymous said...

I feel that is among the most significant info for me.
And i'm happy studying your article. However wanna observation on some general issues, The website style is perfect, the articles is in point of fact great : D. Good job, cheers

Stop by my page - Bmi Calculator Women