一、樹的表示方法
1、雙親表示法
struct node
{
int data;//節點數據
int parent;//父節點在數組中的下標
};
2、孩子表示法
由兩部分組成
1、表頭形成的循序表,存放節點數據和第一個孩子的地址
2、孩子鏈表。有此節點的孩子節點組成的單鏈表
struct CTNode
{
int data;
CTNode *next;
};
struct CBNode{
int data;
CTNode *firstChild;
};
3、孩子兄弟表示法
struct node{
//節點數據
int data;
//firstChild第一個兒子的地址,rightBrother右兒子的地址
node *firstChild,*rightBrother
};