数据结构

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

双亲表示法
//双亲存储表示:
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;
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容