| PREV |
Trees |
NEXT |
| |
(92 / 301) |
|
|
|
|
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);
}
|
| PREV |
COMMENTS INDEX PRINT |
NEXT |
Last updated:
November 3, 2005
www.cracktheinterview.com - Your destination for the most common IT interview questions, answers, frequently asked interview questions (FAQ), C Programs, C Datastructures for technical interviews conducted by the top IT companies around the world!
|
|
|