------树的双亲表示存储------

#define MAX_TREE_SIZE 100;

typedef struct PTNode {

  TElemType data;

  int parent;

}PTNode;

typedef struct {

  PTNode nodes[MAX_TREE_SIZE];

  int r,n;  //根的位置,和节点数

}PTree;

数组下标  

0   1   2  3  4  5  6  7  8  9

R   A  B  C  D  E  F  G  H  K

-1  0  0   0  1  1  3  6  6  6

 

------ 数的孩子链表存储表示------

typedef struct CTNode {  //孩子节点

  int child;

  struct CTNode * next;

}  *ChildPtr;

 typedef struct {

  TElemType data;

  ChildPtr firstchild;

}CTBox;

typedef struct {

  CTBox nodes [ MAX_TREE_SIZE];

  int n,r;

}CTree;

 

------ 数的二叉链表(孩子-兄弟)存储表示------

typedef struct CSNode {

  ElemType data;

  struct CSNode * firstchild, * nextsibling;

}CSNode, *CSTree;

 

 

相关文章:

  • 2021-10-15
  • 2021-06-03
  • 2021-06-09
  • 2021-10-12
  • 2023-02-04
  • 2021-11-15
  • 2021-05-24
  • 2021-10-23
猜你喜欢
  • 2021-12-12
  • 2021-06-22
  • 2021-10-18
  • 2021-06-03
  • 2021-07-29
  • 2021-06-04
  • 2021-08-28
相关资源
相似解决方案