美文网首页
数据结构

数据结构

作者: 寿_司 | 来源:发表于2016-05-05 09:40 被阅读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;
    

    相关文章

      网友评论

          本文标题:数据结构

          本文链接:https://www.haomeiwen.com/subject/rwldrttx.html