Zhejiang University

Understanding of the Puzzle

We simply regard the trees as the same as long as they have the same children for every node.

Divide and Conquer

  • The representation of a binary tree
  • Build a Binary Tree
  • Judge whether they are Isomers.

Representing a Binary Tree

Static Linked List: A Special Array.

Structure of the Program

1
2
3
4
5
6
7
8
BinTree Build();
bool Judge();
int main(){
Build tree1;
Build tree2;
Judge isomers;
return 0;
}

Design the Functions

1
2
3
4
5
6
7
8
#define ElementType char
#define Tree int
#define Null -1
struct TreeNode{
ElementType Element;
Tree Left;
Tree Right;
}T1[MaxTree], T2[MaxTree];