bool treeMatch(shared_ptr<Misc::tNode> &big, shared_ptr<Misc::tNode> & small) { if (!small) return true; if (!big) return false; if (big->data != small->data) return false; return treeMatch(big->left, small->left) && treeMatch(big->right, small->right); }
bool Misc::isSubTree(shared_ptr<tNode> &big, shared_ptr<tNode> &small) { if (!small) return true; if (!big) return false; bool result=false; if (small->data == big->data) result=treeMatch(big, small); if (!result && big->left) result = treeMatch(big->left, small); if (!result && big->right) result = treeMatch(big->right, small); return result; }
int treeMatch(node_4_h* n1, node_4_h* n2) { if(n2 == NULL) return 1; if(n1 == NULL) return 0; if(n1->value!=n2->value) return 0; return(treeMatch(n1->left, n2->left) || treeMatch(n1->right, n2->right)); }
int traverseTree(node_4_h* n1, node_4_h* n2) { if(n1 == NULL) return 0; if(n1->value == n2->value && treeMatch(n1, n2)) return 1; return(traverseTree(n1->left, n2) || traverseTree(n1->right, n2)); }