This function returns true if S is a subtree of T, otherwise false */
| 37 | /* This function returns true if S |
| 38 | is a subtree of T, otherwise false */ |
| 39 | bool isSubtree(node *T, node *S) |
| 40 | { |
| 41 | /* base cases */ |
| 42 | if (S == NULL) |
| 43 | return true; |
| 44 | |
| 45 | if (T == NULL) |
| 46 | return false; |
| 47 | |
| 48 | /* Check the tree with root as current node */ |
| 49 | if (areIdentical(T, S)) |
| 50 | return true; |
| 51 | |
| 52 | /* If the tree with root as current |
| 53 | node doesn't match then try left |
| 54 | and right subtrees one by one */ |
| 55 | return isSubtree(T->left, S) || |
| 56 | isSubtree(T->right, S); |
| 57 | } |
| 58 | |
| 59 | |
| 60 | /* Helper function that allocates |