树的存储

来源:互联网 发布:php图像乱码 编辑:程序博客网 时间:2024/06/08 12:47

树的存储方式

//树的双亲表示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;     //指向第一个孩子的指针}PNode,PTree[Max];//孩子兄弟表示法typedef struct CSNode{ ElemType data; struct CSNode *firstchilde,*nextsibling;}CSNode,*CSTree;


0 0
原创粉丝点击