数据结构

2016-05-05  本文已影响0人  寿_司

参考资料:
树的三种存储方式

双亲表示法
//双亲存储表示:
typedef struct PTNode
{
    TElemType data;
    int parent;//双亲位置域
}PTNode; //结点结构
typedef struct {
    PTNode nodes[100];
    int r,n;//跟的位置和结点数
}PTree;//树结构
孩子链表表示法(带双亲)
//树的孩子链表存储表示:
typedef struct CTNode
{
    int child;
    struct CTNode *next;
} *ChildPtr;//孩子结点
typedef struct 
{
    TElemType data;
    childPtr firstchild;
}CTBox;//孩子链表头指针
typedef struct 
{
    CTBox nodes[100];
    int n,r; //结点数和根的位置
}CTree;
孩子兄弟表示法
//孩子兄弟表示法:
typedef struct CSNode
{
    ElemType data;
    struct CSNode *firstchild,*nextsibling; 
}CSNode,*CSTree;
上一篇 下一篇

猜你喜欢

热点阅读