您的位置:首页 > 理论基础 > 数据结构算法

大话数据结构——树的存储结构

2015-03-19 15:14 162 查看
#include<iostream>

using namespace std;

//树的存储结构
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define MAX 1000
typedef int elemtype;//数据类型

/*双亲表示法的存储结构*/
//根节点的结构
typedef struct PtNode
{
elemtype data;//节点的数据
int parent;//节点双亲的位置
}PtNode;
//树的结构
typedef struct tree
{
PtNode nodes[MAX];//节点数组
int r,n;//根节点的位置,节点数
}tree;

/*孩子表示法*/
//孩子结点
typedef struct CTNode
{
int child;
struct CTNode * next;
}CTNode;

//表头结构
typedef struct CTbox
{
elemtype data;
CTNode *firstchild;
}CTbox;

//树结构
typedef struct CTtree
{
CTbox tree[MAX];//结点数组
int r,n;//根节点位置,节点数
}CTtree;

/*孩子兄弟表示法*/
typedef struct BRNode
{
elemtype data;//结点数据
BRNode *firstchild,*rightchild;//指针域,分别指向第一个孩子和右兄弟。
}BRNode;

int main()
{

}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: