数据结构 二叉树的存储结构

线程二叉树 (Threaded Binary Tree )

A binary tree can be represented by using array representation or linked list representation. When a binary tree is represented using linked list representation. If any node is not having a child we use a NULL pointer. These special pointers are threaded and the binary tree having such pointers is called a threaded binary tree. Thread in a binary tree is represented by a dotted line. In linked list representation of a binary tree, they are a number of a NULL pointer than actual pointers. This NULL pointer does not play any role except indicating there is no child. The threaded binary tree is proposed by A.J Perlis and C Thornton. There are three ways to thread a binary tree.

可以通过使用数组表示形式或链接列表表示形式来表示二叉树 。 当使用链接列表表示形式表示二叉树时。 如果任何节点没有子节点,我们将使用NULL指针。 这些特殊的指针是线程化的,具有此类指针的二进制树称为线程化的二进制树。 二叉树中的线程用虚线表示。 在二叉树的链表表示中,它们是空指针的数量,而不是实际指针的数量。 该NULL指针除指示没有子代外没有任何作用。 线程二叉树由AJ Perlis和C Thornton提出。 线程二叉树的方法有三种。

  1. In the in order traversal When The right NULL pointer of each leaf node can be replaced by a thread to the successor of that node then it is called a right thread, and the resultant tree called a right threaded tree or right threaded binary tree.

    在顺序遍历中,如果每个叶节点的Right NULL指针都可以由指向该节点后继节点的线程替换,则它称为右线程,而生成的树称为右线程树或右线程二叉树。

  2. When The left NULL pointer of each node can be replaced by a thread to the predecessor of that node under in order traversal it is called left thread and the resultant tree will call a left threaded tree.

    当每个节点的Left NULL指针可以按顺序遍历到该节点的前任对象的线程时,称为左线程,结果树将称为左线程树。

  3. In the in order traversal, the left and the right NULL pointer can be used to point to predecessor and successor of that node respectively. then the resultant tree is called a fully threaded tree.

    在顺序遍历中,可以使用左侧和右侧的NULL指针分别指向该节点的前任和后任。 那么生成的树称为全线程树。

In the threaded binary tree when there is only one thread is used then it is called as one way threaded tree and when both the threads are used then it is called the two way threaded tree. The pointer point to the root node when If there is no in-order predecessor or in-order successor.

在线程二叉树中,当仅使用一个线程时,则将其称为单向线程树,而当同时使用两个线程时,则将其称为双向线程树。 如果不存在有序的前任或有序的后任,则指针指向根节点。

Consider the following binary tree:

考虑以下二进制树:

The in-order traversal of a given tree is D B H E A F C G. Right threaded binary tree for a given tree is shown below:

给定树的有序遍历为DBHEAFCG 。 给定树的右线程二叉树如下所示:

线程二叉树的优点 (Advantages of Thread Binary Tree)

Non-recursive pre-order, in-order and post-order traversal can be implemented without a stack.

无需堆栈即可实现非递归的有序遍历,有序遍历和后遍历遍历。

线程二叉树的缺点 (Disadvantages of Thread Binary Tree)

  1. Insertion and deletion operation becomes more difficult.

    插入和删除操作变得更加困难。

  2. Tree traversal algorithm becomes difficult.

    树遍历算法变得困难。

  3. Memory required to store a node increases. Each node has to store the information whether the links is normal links or threaded links.

    存储节点所需的内存增加。 无论链接是普通链接还是线程链接,每个节点都必须存储信息。

.minHeight{ min-height: 250px; } @media (min-width: 1025px){ .minHeight{ min-height: 90px; } } .minHeight{ min-height: 250px; } @media (min-width: 1025px){ .minHeight{ min-height: 90px; } }

二叉树的线程类型 (Types of Threaded of Binary Tree)

There are three types of Threaded Binary Tree,

线程二叉树有三种类型,

1) Right Threaded Binary Tree

1)右线程二叉树

Right threaded binary tree for a given tree is shown:

显示给定树的右线程二叉树:

2) Left Threaded Binary Tree

2)左线程二叉树

Left threaded binary tree for a given tree is shown:

显示给定树的左线程二叉树:

3) Fully Threaded Binary Tree

3)全线程二叉树

Fully threaded binary tree for a given tree is shown:

显示给定树的全线程二叉树:

翻译自: https://www.includehelp.com/data-structure-tutorial/threaded-binary-tree.aspx

数据结构 二叉树的存储结构

数据结构 二叉树的存储结构_线程二叉树| 数据结构相关推荐

  1. 数据结构实验报告-二叉树的存储结构的实现与应用

    实验目的 熟悉二叉树结点的结构和对二叉树的基本操作. 掌握对二叉树每一种操作的具体实现. 学会利用递归方法编写对二叉树这种递归数据结构进行处理的算法. 在二叉树基本操作的基础上掌握二叉树的应用. 实验 ...

  2. 再谈二叉树(二叉树概念,二叉树的性质,二叉树的存储结构)

    树的概念 树的概念 树是一种非线性的数据结构,它是由n(n>=0)个有限结点组成一个具有层次关系的集合.把它叫做树是因 为它看起来像一棵倒挂的树,也就是说它是根朝上,而叶朝下的.它具有以下的特点 ...

  3. 二叉树的存储结构及四种遍历(C语言)

    二叉树的存储结构: typedef struct TNode *Position; typedef Position BinTree; /* 二叉树类型 */ struct TNode{ /* 树结点 ...

  4. 二叉树的链式存储结构(线索二叉树)

    一.链式存储结构 由于顺序存储二叉树的空间利用率较低,因此二叉树一般都采用链式存储结构,用链表结点来存储二叉树中的每个结点.在二叉树中,结点结构通过包括若干数据域和若干指针域,二叉链表至少包含3个域: ...

  5. 数据结构和数据存储结构

    数据结构和数据存储结构 数据结构和数据存储结构是不同的:一个是逻辑概念上的一个是真实存储在计算机上的 数据的存储结构:顺序.链式.索引.散列 数据的存储结构是针对计算机来说的,指的是数据的逻辑结构在计 ...

  6. 20.0、C语言数据结构——图的存储结构

    20.0.C语言数据结构--图的存储结构 图的存储结构相比较线性表与树来说就复杂很多了: 1. 我们回顾下,对于线性表来说,是一对一的关系,所以用数组或者链表均可简单存放:树结构是一对多的关系,所以我 ...

  7. 数据结构与算法(6-2)二叉树的存储结构(顺序存储、链式存储)

    目录 一.二叉树的顺序存储 存储方式 总代码 二.二叉树的链式存储(二叉链表) 1.存储结构 2.创建二叉树 总代码 一.二叉树的顺序存储 存储方式 //树的顺序存储 typedef struct { ...

  8. 二叉树的存储结构入门(java描述)

    1. 顺序存储结构 所谓二叉树的顺序存储,就是用一组连续的存储单元存放二叉树中的结点.一般是按照二叉树结点从上至下.从左到右的顺序存储.这样结点在存储位置上的前驱.后继关系并不一定就是它们在逻辑上的邻 ...

  9. python树结构_数据结构的树存储结构

    之前介绍的所有的数据结构都是线性存储结构.本章所介绍的树结构是一种非线性存储结构,存储的是具有"一对多"关系的数据元素的集合. (A)                       ...

最新文章

  1. dba mysql命令_Mysql常用DBA命令
  2. 查看coo_matrix的shape
  3. 高性能网站建设之 MS Sql Server数据库分区
  4. 爬虫实战学习笔记_2 网络请求urllib模块+设置请求头+Cookie+模拟登陆
  5. 节前福利:Java程序员面试宝典升级版
  6. php 赋值给 dom对象,详解PHP原生DOM对象操作XML的方法
  7. OAuth 及 移动端鉴权调研
  8. 传奇服务器修改变量,课程列表-传奇服务端制作修改教程-4.3变量-学传奇
  9. VB计算机中next是什么意思,VB程序的基本结构――循环结构之For-Next语句
  10. 手机三十分钟熄屏如何一直亮_怎么让手机屏幕一直亮着
  11. ResourceBundle读取properties文件
  12. 使用长时间运行作业的警报监控SQL代理
  13. 软件平台与中间技术复习
  14. bl小说里面有个机器人管家_不久的未来 有个“机器人管家”或不再是梦想
  15. codeforces竞赛1141题解
  16. 将openwrt软路由装进U盘中并运行
  17. strstr函数和strtok函数的使用
  18. python外星人实验报告_Python 项目实践一(外星人入侵)第一篇
  19. AI 新技术革命将如何重塑就业和全球化格局?深度解读 UN 报告(上篇)
  20. 象棋人机java代码,java象棋人机对战

热门文章

  1. Ext grid js上移下移样例
  2. 用 CSS 实现元素垂直居中,有哪些好的方案?
  3. Npm install failed with “cannot run in wd”
  4. 深入理解脚本化CSS系列第二篇——查询计算样式
  5. 替换富文本里的px为rem
  6. vue获取DOM元素并设置属性
  7. Animate.css介绍
  8. 课时39.细线表格(理解)
  9. windows2008 sp2 x64安装 ocs 2007 r2 笔记
  10. python链表的实现,有注释