left-child right-sibling representation - 左孩子右兄弟表示

left-child right-sibling representation - 左孩子右兄弟表示

Left-Child Right-Sibling Representation is a different representation of an n-ary tree where instead of holding a reference to each and every child node, a node holds just two references, first a reference to it’s first child, and the other to it’s immediate next sibling. This new transformation not only removes the need of advance knowledge of the number of children a node has, but also limits the number of references to a maximum of two, thereby making it so much easier to code.
Left-Child Right-Sibling Representation 是 n 元树的另一种表示形式,一个节点不保存对每个子节点的引用,而仅保留两个引用,一个对它的第一个子节点的引用,另一个对它的下一个兄弟节点的引用。这种新的转变不仅消除了对节点拥有的子节点数量的预先了解的需要,而且还将引用数限制为最多两个,从而使编码变得如此容易。

At each node, link children of same parent from left to right. Parent should be linked with only first child.
在每个节点上,从左到右链接同一父级的子级。父级应仅与第一个子级联系。

1. Left Child Right Sibling tree representation

      10
      |  
      2 -> 3 -> 4 -> 5
      |    |  
      6    7 -> 8 -> 9
typedef struct NODE {
	int data;
	struct NODE *first_child;
	struct NODE *right_sibling;
} Node;

References

https://www.geeksforgeeks.org/creating-tree-left-child-right-sibling-representation/
在线 IDE
https://ide.geeksforgeeks.org/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Yongqiang Cheng

梦想不是浮躁,而是沉淀和积累。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值