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

child-sibling representation, left-child, right-sibling binary tree, doubly chained tree or filial-heir chain.

binary tree:二叉树
left-child right-sibling,LCRS:左孩子右兄弟
sibling ['sɪblɪŋ]:n. 兄,弟,姐,妹
filial ['fɪliəl]:adj. 子女 (对父母) 的
heir [eə(r)]:n. 继承人,后嗣,传人
multi-way tree - k-ary tree

1. LC-RS binary tree

In a binary tree that represents a multi-way tree T T T, each node corresponds to a node in T T T and has two pointers: one to the node’s first child, and one to its next sibling in T T T. The children of a node thus form a singly-linked list.
在表示多路树 T T T 的二叉树中,每个节点对应于 T T T 中的一个节点,并且具有两个指针:一个指向节点的第一个子节点,另一个指向在 T T T 中的下一个子节点。因此,节点的子级形成一个单链表。

The process of converting from a k-ary tree to an LC-RS binary tree is sometimes called the Knuth transform. To form a binary tree from an arbitrary k-ary tree by this method, the root of the original tree is made the root of the binary tree. Then, starting with the root, each node’s leftmost child in the original tree is made its left child in the binary tree, and its nearest sibling to the right in the original tree is made its right child in the binary tree.
k-ary 树转换为 LC-RS 二叉树的过程有时称为 Knuth transform。为了通过这种方法从任意的 k-ary 树形成二叉树,将原始树的根设为二叉树的根。

Processing a k-ary tree to LC-RS binary tree, every node is linked and aligned with the left child, and the next nearest is a sibling.
k-ary 树处理为 LC-RS 二叉树,每个节点都与左子节点链接并对齐,下一个最近的节点是同级节点。

a ternary tree

                  1/|\/ | \/  |  \2   3   4/ \      |5   6     7/ \8   9

We can re-write it by putting the left child node to one level below its parents and by putting the sibling next to the child at the same level – it will be linear (same line).
我们可以通过以下方式重新编写它:将左侧的子节点放置在其父节点以下一级,并在同一级别将子节点旁边的同级节点放置为线性 (同一行)。

                  1///2---3---4/       /5---6   7/8---9

The LCRS representation is more space-efficient than a traditional multiway tree, but comes at the cost that looking up a node’s children by index becomes slower. Therefore, the LCRS representation is preferable if
LCRS 表示比传统的多路树更节省空间,但代价是按索引查找节点的子代变慢。因此,如果满足以下条件,则最好使用 LCRS 表示形式

  1. Memory efficiency is a concern. (内存效率。)
  2. Random access of a node’s children is not required. (不需要节点的子级的随机访问。)

Case (1) applies when large multi-way trees are necessary, especially when the trees contains a large set of data. For example, if storing a phylogenetic tree, the LCRS representation might be suitable.
情况 (1) 适用于需要大型多路树的情况,尤其是当树包含大量数据时。 例如,如果存储系统树,则 LCRS 表示可能是合适的。

Case (2) arises in specialized data structures in which the tree structure is being used in very specific ways. For example, many types of heap data structures that use multi-way trees can be space optimized by using the LCRS representation.
情况 (2) 出现在特殊的数据结构中,其中以非常特定的方式使用树结构。例如,可以使用 LCRS 表示对使用多路树的许多类型的堆数据结构进行空间优化。

2. trie

A trie implemented as a doubly chained tree: vertical arrows are child pointers, dashed horizontal arrows are next-sibling pointers.
一个实现为双链树的 trie:垂直箭头是子指针,虚线水平箭头是下一个兄弟指针。

References

https://www.geeksforgeeks.org/left-child-right-sibling-representation-tree/
https://www.geeksforgeeks.org/creating-tree-left-child-right-sibling-representation/
https://en.wikipedia.org/wiki/Left-child_right-sibling_binary_tree

left-child right-sibling representation of tree - 左孩子右兄弟表示树相关推荐

  1. 辅助类BinaryTreeNodeLeftChildRightSibling(左孩子右兄弟,二叉树结点)

    辅助类BinaryTreeNodeLeftChildRightSibling(左孩子右兄弟,二叉树结点) template<typename T> class BinaryTreeNode ...

  2. strcmp() Anyone? UVA - 11732 左孩子右兄弟Trie/计数

    #include<bits/stdc++.h> using namespace std; #define ll long longconst int maxnode = 4000 * 10 ...

  3. java实现家庭关系图_左孩子右兄弟二叉树实现家族家谱

    /* Name: 家谱 Description: 本项目对家谱管理进行简单的模拟,以实现查看祖先和子孙个人信息.插入家族成员.删除家族成员等功能. */ #include #include using ...

  4. 3422. 左孩子右兄弟

    对于一棵多叉树,我们可以通过 "左孩子右兄弟" 表示法,将其转化成一棵二叉树. 如果我们认为每个结点的子结点是无序的,那么得到的二叉树可能不唯一. 换句话说,每个结点可以选任意子结 ...

  5. 多叉树的二叉树表示法(左儿子右兄弟)

    在二叉树的基础上,我们可以扩展出任意多个叉的树.即,多叉树.然而,此时又面临着另外一个问题: 当孩子结点无限制时,我们并不知道预先要分配多少个属性,且当仅有少数元素拥有多个子节点时,将会造成大量的空间 ...

  6. 第十二届蓝桥杯省赛A组试题:左儿子右兄弟Java

    [问题描述] 对于一棵多叉树,我们可以通过 "左孩子右兄弟" 表示法,将其转化成一棵二叉树.如果我们认为每个结点的子结点是无序的,那么得到的二叉树可能不唯一.换句话说,每个结点可以 ...

  7. 蓝桥杯 左baby右兄弟

    试题: 思路: "左孩子右兄弟"是常见的多叉树转化成二叉树的方法.具体的实现方式是,从第二层最右边的结点开始,将将自己的孩子结点放到左边,左边一位的兄弟放到左边的结点上.对于是多支 ...

  8. java中的左值右值_利用左值右值实现树状结构

    image.png 1. 查询 1.1. 得到节点 Node 下的所有节点,并按树状排序 SELECT * FROM tree WHERE lft BETWEEN Node.Lft AND Node. ...

  9. 试题H 左Children右兄弟

    (吐槽:为什么不能使用'孩'和'子'这两个字) 题目链接:https://www.lanqiao.cn/courses/2786/learning/?id=280825 题目解析:典型的树形DP 记d ...

最新文章

  1. freemark 时间比较
  2. Dynamic Web Module 3.0 requires Java 1.6 or newer.
  3. 办学10年,进入全国前10名!这所神奇的高校,迎来10岁生日
  4. 一个form 如何做两次提交_如何做一个优秀的家长
  5. linux下限制一个文件夹大小的方法
  6. VSCode 插件离线安装方法(转载)
  7. 递归算法计算八皇后问题(Eight Queen Problem with Recursive Algorithm)
  8. 在OSM上下载历史数据
  9. python发送soap报文_使用Python将带附件的XML发送到SOAP ws
  10. 人工智能——Search搜索问题
  11. Python-爬虫(Scrapy爬虫框架,爬取豆瓣读书和评分)
  12. 纯配置方式使用durid的数据库密码加密
  13. PageRank 算法初步了解
  14. 数据结构思维导图——线性表(最全)
  15. 瑞芯微RK3399Pro平台YOLOv4 pytorch模型转RKNN模型失败
  16. teraterm软件download的地址
  17. 运行工程时报:failed parsing overlays
  18. Android.mk的用法和基础 m、mm、mmm编译命令
  19. 五子棋规则的实现及代码
  20. java 什么是免检异常_RuntimeException及其子类在异常处理时可以不必处理,属于免检异常。...

热门文章

  1. 每日一课 | Python数据可视化—多样化的图像
  2. 成都精灵云C++ 一面(20min)
  3. 利用for 语句求奇数,for语句,求奇数;
  4. 计算机运维相关专业知识考试,计算机项目运维人员考什么证书
  5. Android Studio调用python读取图片(使用服务器paddlehub处理图片)
  6. nginx日志报警|微信公众号推送预警消息|PHP+shell脚本实现nginx错误日志报警恶意访问报警,实时通知到微信公众号 | 小型网站nginx日志报警轻量级方案
  7. 斗拱展开面积表_中国传统古建筑斗拱.pdf
  8. endnote与中文(毕业)论文的小操作(有缘更新)
  9. 【web】HTTP头信息解读
  10. 十连胜!实在智能×浙江省十家农商行,数字科技赋能普惠金融