Data Structures and Algorithms (English) - 6-7 Isomorphic(20 分)

简介: Data Structures and Algorithms (English) - 6-7 Isomorphic(20 分)

题目链接:点击打开链接

题目大意:略。

解题思路:略。

AC 代码

intIsomorphic(TreeT1, TreeT2)
{
intflag=1, flag1=1, flag2=1, flag3=1, flag4=1;
if (T1!=NULL&&T2!=NULL)
    {
if (T1->Element!=T2->Element)
flag=0;
else        {
flag1=Isomorphic(T1->Left, T2->Left);
flag2=Isomorphic(T1->Left, T2->Right);
flag3=Isomorphic(T1->Right, T2->Left);
flag4=Isomorphic(T1->Right, T2->Right);
flag= (flag1&&flag4) || (flag2&&flag3);
//            flag = (flag1||flag2) && (flag3||flag4); // 错误的想法        }
    }
elseif (T1==NULL&&T2!=NULL)
flag=0;
elseif (T1!=NULL&&T2==NULL)
flag=0;
returnflag;
}
目录
相关文章
|
机器学习/深度学习 算法
Data Structures and Algorithms (English) - 7-28 Review of Programming Contest Rules(30 分)
Data Structures and Algorithms (English) - 7-28 Review of Programming Contest Rules(30 分)
216 0
Data Structures and Algorithms (English) - 7-28 Review of Programming Contest Rules(30 分)
|
存储 容器
Data Structures and Algorithms (English) - 7-18 Hashing - Hard Version(30 分)
Data Structures and Algorithms (English) - 7-18 Hashing - Hard Version(30 分)
222 0
Data Structures and Algorithms (English) - 7-18 Hashing - Hard Version(30 分)
Data Structures and Algorithms (English) - 6-8 Percolate Up and Down(20 分)
Data Structures and Algorithms (English) - 6-8 Percolate Up and Down(20 分)
105 0
Data Structures and Algorithms (English) - 6-15 Iterative Mergesort(25 分)
Data Structures and Algorithms (English) - 6-15 Iterative Mergesort(25 分)
193 0
Data Structures and Algorithms (English) - 7-9 Huffman Codes(30 分)
Data Structures and Algorithms (English) - 7-9 Huffman Codes(30 分)
104 0
Data Structures and Algorithms (English) - 6-1 Deque(25 分)
Data Structures and Algorithms (English) - 6-1 Deque(25 分)
102 0
Data Structures and Algorithms (English) - 6-13 Topological Sort(25 分)
Data Structures and Algorithms (English) - 6-13 Topological Sort(25 分)
112 0
Data Structures and Algorithms (English) - 6-16 Shortest Path [3](25 分)
Data Structures and Algorithms (English) - 6-16 Shortest Path [3](25 分)
106 0
Data Structures and Algorithms (English) - 6-11 Shortest Path [1](25 分)
Data Structures and Algorithms (English) - 6-11 Shortest Path [1](25 分)
117 0
Data Structures and Algorithms (English) - 6-11 Shortest Path [2](25 分)
Data Structures and Algorithms (English) - 6-11 Shortest Path [2](25 分)
128 0

热门文章

最新文章