判断一棵树是另一棵树的子结构  

bool DFS(struct TreeNode *head,struct TreeNode *head2)
    {
        if(head2==NULL)
          return true;
        if(head==NULL)
          return false;
        bool ans=false;
        if(head->val==head2->val)
        {
            ans=DFS(head->left,head2->left);
            if(!ans)
            {
                return false;
            }
            ans=DFS(head->right,head2->right);
        }
        return ans;
    }
    bool HasSubtree(TreeNode* pRoot1, TreeNode* pRoot2)
    {
           if(!pRoot1||!pRoot2)
           {
                  return false;
           }
           bool ans=false;
           if(pRoot1->val==pRoot2->val)
           {
                 ans=DFS(pRoot1,pRoot2);
           }
           if(!ans)
             ans=HasSubtree(pRoot1->left,pRoot2);
            if(!ans)
             ans=HasSubtree(pRoot1->right,pRoot2);
           return ans;
    }