class BinaryTreeNode {
public:
int value;
BinaryTreeNode* left;
BinaryTreeNode* right;
};
bool DoesTreeOneHaveTreeTwo(BinaryTreeNode * root1, BinaryTreeNode* root2){
if (root2 == NULL)return true;
if (root1 == NULL) return false;
if (root1->value != root2->value) return false;
return DoesTreeOneHaveTreeTwo(root1->left,root2) && DoesTreeOneHaveTreeTwo(root1->right, root2);
}
bool HasSubTree(BinaryTreeNode * root1, BinaryTreeNode* root2) {
bool result = false;
if (root1 != NULL && root2 != NULL) {
if (root1->value == root2->value)result = DoesTreeOneHaveTreeTwo(root1, root2);
if (!result)result = HasSubTree(root1->left, root2);
if (!result)result = HasSubTree(root1->right, root2);
}
return result;
}
bool total(BinaryTreeNode * root1, BinaryTreeNode* root2) {
if (root1 == NULL && root2 == NULL) return false;
if (root1 == NULL && root2 != NULL)return false;
if (root1 != NULL && root2 == NULL) return true;
return HasSubTree(root1, root2);
}