数据结构 二叉树的存储结构_线程二叉树| 数据结构

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

线程二叉树 (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:

考虑以下二进制树:

Threaded Binary Tree 1

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.

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

二叉树的线程类型 (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:

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

Right Threaded Binary Tree

2) Left Threaded Binary Tree

2)左线程二叉树

Left threaded binary tree for a given tree is shown:

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

Left Threaded Binary Tree

3) Fully Threaded Binary Tree

3)全线程二叉树

Fully threaded binary tree for a given tree is shown:

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

Fully Threaded Binary Tree

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

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/378438.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

七、有机硅柔软剂在不同发展阶段分子结构特征及主要解决的问题?

有机硅柔软剂在不同发展阶段分子结构特征及主要解决的问题? 收集资料阶段 聚有机硅氧烷具有低表面能、优良的润滑性、热稳定性和疏水性。从分子层面分析,经聚有机硅氧烷处理的织物,其柔软性来自硅氧烷骨架中 Si—O—Si键的 360自由旋转及甲基之间的低相互作用。因此,聚有机…

【智能车Code review】——拐点的寻找

博主联系方式: QQ:1540984562 QQ交流群:892023501 群里会有往届的smarters和电赛选手,群里也会不时分享一些有用的资料,有问题可以在群里多问问。 系列文章 【智能车Code review】—曲率计算、最小二乘法拟合 【智能车Code review】——坡道图像与控制处理 【智能车Code re…

linux 单例模式改密码,Java 利用枚举实现单例模式

引言单例模式比较常见的实现方法有懒汉模式,DCL模式公有静态成员等,从Java 1.5版本起,单元素枚举实现单例模式成为最佳的方法。Java枚举基本用法枚举的用法比较多,本文主要旨在介绍利用枚举实现单例模式的原理,所以这里…

编码简介

编码简介最近被字符集搞得头大,基于为自己扫盲的目的,索性收集资料研究一下,现将各方资料归纳成本文。这里并不想把复杂的规则说明一大通。如有需要,请参照其他资料或本文给出的参考资料。 如有错误,欢迎指正。…

2013年5月7日---JS中的正则

/*(1)RegExp对象的test方法------------------C#中的isMatchvar num1d23; //一个字符串var regnew RegExp(^\\d$); //准备正则alert(reg.test(num)); //开始匹配并弹出--false*//*(2)ReExp对象的test方法var num123;var regnew RegExp(/^\d$/);ale…

八、关于防水透湿整理

1,防水透湿整理加工技术的类型? 收集资料阶段 按照加工方式分类 防水透湿织物按照加工方式可分为高密织物、涂层织物和层压织物。不同加工方式所对应的织物各有特色。高密织物产生于 20 世纪 80 年代,它的密度可达到普通织物的 20 倍。在晴朗天气时,纱线孔隙大约为 10 μm…

linux qt 音频文件怎么打开,Qt:获取Linux中可用音频设备的列表

我想要获取我的Linux系统上可用的所有音频设备的列表。然后我会将这个列表显示在一个组合框中,用户将从中选择用于录制/播放的设备。根据用户的选择,我将构建QAudioInput和QAudioOutput进行录制/播放。Qt:获取Linux中可用音频设备的列表根据Q…

c# uri.host_C#| Uri.GetLeftPart()方法与示例

c# uri.hostUri.GetLeftPart()方法 (Uri.GetLeftPart() Method) Uri.GetLeftPart() method is an instance method that is used to get a specified part from the given URI based on passed UriPartial enum. Uri.GetLeftPart()方法是一个实例方法,用于基于传递的…

求质数算法的N种境界 (N 10) zz

★引子 前天,俺在《俺的招聘经验[4]:通过笔试答题能看出啥?》一文,以"求质数"作为例子,介绍了一些考察应聘者的经验。由于本文没有政治敏感内容,顺便就转贴到俺在CSDN的镜像博客。   昨天&…

【智能车Code review】——小S与中S道路判断

博主联系方式: QQ:1540984562 QQ交流群:892023501 群里会有往届的smarters和电赛选手,群里也会不时分享一些有用的资料,有问题可以在群里多问问。 系列文章 【智能车Code review】—曲率计算、最小二乘法拟合 【智能车Code review】——坡道图像与控制处理 【智能车Code re…

Python匿名函数---排序

一、列表的排序 nums [1,2,3,5,4,7,87,4,9,56,44,7,5] nums.sort()#默认从小到大排序 nums#结果为:[1, 2, 3, 4, 4, 5, 5, 7, 7, 9, 44, 56, 87]nums [1,2,3,5,4,7,87,4,9,56,44,7,5] nums.sort(reverseTrue)#从大到小排序 nums#结果为:[87, 56, 44, …

linux 内核编译需要多大空间,编译2.6.28内核出错。。。。空间不足。而/tmp/还有好几G...

编译2.6.28内核出错。。。。空间不足。而/tmp/还有好几G发布时间:2009-01-02 16:56:47来源:红联作者:weixq316今天闲来无事,就去下载了最新的内核--2.6.28来编译安装。。。:0)1放在/usr/src/2.6.28/中编译。。。。。我的/usr还有1G多的空间。…

如何用vi 复制第5行到第10行并粘贴到第12行之后

方法一: 光标放到第五行,输入:y6y光标放到第12行,输入:p方法二:命令行模式下输入:5,10 co 12方法三:延伸一下, 有时候不想费劲看多少行或复制大量行时,可以使用标签来替代光标移到起…

go zap去除程序名称_适用于Zip,Zap和Zoom游戏的Python程序

go zap去除程序名称Write a python program that displays a message as follows for a given number: 编写一个python程序,显示给定数字的消息如下: If it is a multiple of three, display "Zip". 如果是三的倍数,则显示“ Zip…

【智能车Code review】——环岛的判定与补线操作

博主联系方式: QQ:1540984562 QQ交流群:892023501 群里会有往届的smarters和电赛选手,群里也会不时分享一些有用的资料,有问题可以在群里多问问。 视频讲解 这里是对于代码的讲解视频,大约一个小时,需要的同学可以看看:B站:meeting_01 系列文章 【智能车Code review】…

Python交换两个变量的三种方法

一、借助于第三个变量(很常用) a 5 b 6c 0 c a a b b c print("a%d,b%d"%(a,b))#结果为:a6,b5二、如何不借助第三个变量实现两个变量交换数据呢? a 5 b 6a ab b a-b a a-b print("a%d,b%d"%(a,b))#结果为:a…

linux下怎么查kill某个进程,Linux下查询进程PS或者杀死进程kill的小技巧

假设我们要kill掉tomcat:那么我们首先需要tomcat的进程号pid:ps -aux | grep tomcat记下tomcat的PID后,执行:kill PID(tomcat)好了,就到这里....路人甲:小的们,灭了这个欺骗人民情感的家伙&…

【笔记】VB控件MSComm功能介绍

VB中的MSComm 控件通过串行端口传输和接收数据,为应用程序提供串行通讯功能。MSComm控件在串口编程时非常方便,程序员不必去花时间去了解较为复杂的API函数,而且在VC、VB、Delphi等语言中均可使用。 Microsoft Communications Control&#x…

string charat_Java String charAt()方法与示例

string charat字符串charAt()方法 (String charAt() Method) charAt() method is a String class method in Java, it is used to get the character from specified index from a given string. charAt()方法是Java中的String类方法,用于从给定字符串的指定索引中获…

opencv模板匹配

matchTemplate函数参数 模板匹配是通过模板在采集到的原图像进行滑动寻找与模板图像相似的目标。模板匹配不是基于直方图的方式,而是基于图像的灰度匹配。 6种匹配度量方法: 平方差匹配法CV_TM_SQDIFF 归一化平方差匹配法CV_TM_SQDIFF_NORMED 相关匹配…