树的存储

前端之家收集整理的这篇文章主要介绍了树的存储前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

树的存储方式

//树的双亲表示 typedef struct{ //节点结构 ElemType data; //元素 int parent; //双亲位置 }PTNode; typedef struct{ //树 PTNode nodes[Max]; int n; //树的节点个数 }PTree; //孩子表示法 typedef struct{ //孩子结点 int child; //孩子位置 struct CNode* next; }CNode; typedef struct{ ElemType data; CNode *next; //指向第1个孩子的指针 }PNode,PTree[Max]; //孩子兄弟表示法 typedef struct CSNode{ ElemType data; struct CSNode *firstchilde,*nextsibling; }CSNode,*CSTree;


猜你在找的PHP相关文章