6-7 Isomorphic (20分)

 

 

 

 

 

 解题思路:递归判断

int Isomorphic( Tree T1, Tree T2 )
{
    if(!T1&&!T2)
    return 1;
    else if(T1&&!T2)
    return 0;
    else if(!T1&&T2)
    return 0;
    else
    {
        if(T1->Element==T2->Element)
        {
            return  (Isomorphic(T1->Left,T2->Left)||Isomorphic(T1->Left,T2->Right))&&(Isomorphic(T1->Right,T2->Left)||Isomorphic(T1->Right,T2->Right));
        }
        else
        return 0;     
    }
}

 

posted @ 2020-04-21 12:39  跃鱼  阅读(351)  评论(0编辑  收藏  举报