Write C code to determine if two trees are identical

Here is a C program using recursion

  1. int identical(struct node* a, struct node* b)
  2. {
  3. if (a==NULL && b==NULL){return(true);}
  4. else if (a!=NULL && b!=NULL)
  5. {
  6. return(a->data == b->data &&
  7. identical(a->left, b->left) &&
  8. identical(a->right, b->right));
  9. }
  10. else return(false);
  11. }