您的位置:首页 > 其它

非二叉树转二叉树的表示法

2016-05-01 11:15 323 查看
//树的存储结构,详细图解分析在 秦玉平 马靖善所编的数据结构(第三版) p137-142*/
#include<stdio.h>
#define MAX 100
typedef char Elemtype;
//双亲表示法
typedef struct{
Elemtype node;
int father;
}PTNode;
typedef struct{
PTNode nodes[MAX];
int n;
}PTree;

//孩子双亲表示法,若需要孩子链表表示法,则删除CTBox中的parent就行
typedef struct Node
{
int child;
struct Node *next;
}CTnode,*ChildPtr;
typedef struct{
Elemtype data;
ChildPtr FirstChild;
int parent;
}CTBox;
typedef struct{
CTBox nodes[MAX];
int n;
}CTtree;
//以上三种结构都是用顺序表形式表示树和森林,这很难转换成二叉树的存储形式,也就不能用二叉树中的理论和结构来描述树和森林
//孩子兄弟表示法,这种方法可以把树转变为二叉树
typedef struct CSNode{
Elemtype data;
struct CSNode *firstnode,*nextsibling;
}CSNode,*CSTree;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: