数据结构-数
树的存储结构:
- 双亲表示法
- 孩子表示法
- 孩子兄弟表示法
双亲表示法:
双亲表示法中,在每个结点中,附设一个指示器指示其双亲结点到链表中的位置。
双亲表示法的结构定义:
#define MAX_TREE_SIZE 100 typedef int TElemType; typedef struct PTNode { TElemType data; int parent; } PTNode; typedef struct { PTNode nodes[MAX_TREE_SIZE]; int r,n; /*root position and point*/ } PTree;
孩子兄弟表示法:
原理:任意一棵树,它的结点的第一个孩子如果存在就是唯一的,它的右兄弟结点如果存在也是唯一的。
结构定义
#define TElemType int typedef struct CSNode { TElemType data; struct CSNode *Firstchild, *NextSibling; } CSNode, *CSTree;
孩子表示法:
把每个结点的孩子结点排列起来,以单链表作为存储结构。则n个结点有n个孩子链表,如果是叶子结点,则这个单链表为空。然后n个头指针双组成一个线性表,采用顺序存储结构,存放在一个一唯数组中。
结构定义:
#define MAX_TREE_SIZE 100 /*孩子结点*/ typedef struct CTNode { int child; struct CTNode *next; } *childPtr; /*表头结构*/ typedef struct { TElemType data; ChildPtr firstchild; } CTBox; /*树结构*/ typedef struct { CTBox nodes[MAX_TREE_SIZE]; int r,n; }
2024年1月15日 22:37
Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. <a href="https://linktr.ee/ReubenGloverJr">Easy1Up Review</a>
2024年2月12日 19:16
You completed a number of nice points there. I did a search on the issue and found nearly all people will have the same opinion with your blog.
2024年2月12日 19:30
Tinned copper flat wire are widely used in the solar power industry as interconnect ribbons which are soldered onto the silicon cell – take away the energy produced photoelectrically. The connection of these interconnect ribbons with the rectifier takes place via the so-called busbars – slightly larger copper ribbons that are also tinned.
2024年2月12日 19:56
I just found this blog and have high hopes for it to continue. Keep up the great work, its hard to find good ones. I have added to my favorites. Thank You.
2024年2月12日 21:39
This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here keep up the good work
2024年2月13日 03:25
This is very interesting content! I have thoroughly enjoyed reading your points and have come to the conclusion that you are right about many of them. You are great.
2024年2月13日 03:57
A cd player is a great addition to any music player. They provide an easy way for you to expand the amount of music that is available to you. And with their small size, they can be easily attached to your wall or counter.
2024年2月23日 23:00
I enjoy each of the perform that you have placed into this. I’m sure that you will be making a really useful place. I has been additionally pleased. Good perform!