当前位置:网站首页>C # clue binary tree through middle order traversal
C # clue binary tree through middle order traversal
2022-06-29 12:47:00 【Dusk and starry sky】
This article explains
C# Cue the binary tree through middle order traversal
A binary tree with clues added to its nodes is called a threaded binary tree , In some way of traversing a binary tree ( In the same order 、 Middle preface 、 After the order or level, etc ) Traversal , The process of turning it into a threaded binary tree is called threaded binary tree . [1]
about n A binary tree of nodes , In the binary chain storage structure, there are n+1 An empty chain field , These empty chain fields are used to store the pointers of the precursor node and the successor node of the node in a certain traversal order , These pointers are called cues , A binary tree with clues is called a threaded binary tree .
This kind of binary list with clues is called clue list , The corresponding binary tree is called the clue binary tree (Threaded BinaryTree). According to the nature of the clue , Clue binary tree can be divided into preorder clue binary tree 、 There are three kinds of binary trees: middle order clue binary tree and post order clue binary tree .
Be careful : The clue linked list solves the problem that the precursor and successor nodes of the node in a certain traversal sequence cannot be found directly , Solved the problem of binary linked list to find the left 、 The difficult problem of the right child .
///
/// Cue binary tree through middle order traversal
///
///
///
static void InThread(ref ThreadNode p, ref ThreadNode pre)
{
if (p != null)
{
InThread(ref p.lchild,ref pre);
if (p.lchild == null) { p.lchild = pre; p.ltag = 1; }
if (pre!=null&&pre.rchild==null) { pre.rchild = p;pre.rtag = 1; }
pre = p;
InThread(ref p.rchild, ref pre);
}
}
///
/// Create clue binary tree main logic
///
///
static void CreateInThread(ref ThreadNode T) {
ThreadNode pre = null;
if (T!=null) {
InThread(ref T,ref pre);
pre.rchild = null;
pre.rtag = 1;
}
边栏推荐
- Qt中的UI文件介绍
- Gbase8s database into standard and into raw clauses
- 从Mpx资源构建优化看splitChunks代码分割
- 《高难度谈话》突破谈话瓶颈,实现完美沟通
- C#通过中序遍历对二叉树进行线索化
- Uncover the practice of Baidu intelligent test in the field of automatic test execution
- Newton inequality
- Gbase8s database select has an order by clause
- How to fix ORA-01017:用户名/口令无效 登录拒绝
- 二十三、1-Bit数据的存储(延迟线/磁芯/DRAM/SRAM/磁带/磁盘/光盘/Flash SSD)
猜你喜欢

Interview shock 61: tell me about MySQL transaction isolation level?

Bison uses error loop records

测试--自动化测试:关于unittest框架

Method area of JVM

C#实现图的邻接矩阵和邻接表结构

Recurrence of recommended models (IV): multi task models esmm and MMOE
![[cloud native] 2.4 kubernetes core practice (middle)](/img/1e/b1b22caa03d499387e1a47a5f86f25.png)
[cloud native] 2.4 kubernetes core practice (middle)

Testing -- automated testing: about the unittest framework

ERP Kingdee for preparing BOM

Cache consistency, delete cache, write cache, cache breakdown, cache penetration, cache avalanche
随机推荐
InDesign plug-in - general function development -js debugger open and close -js script development -id plug-in
Gbase 8s extended external connection 1
C#通过线索二叉树进行中序遍历输出
qt json
ERP preparation of BOM basis
【云原生】2.4 Kubernetes 核心实战(中)
1. opencv realizes simple color recognition
[Junzheng T31] decompression and packaging of read-only rootfs file system squashfs
1. Opencv实现简单颜色识别
[JUC series] ThreadLocal of synchronization tool class
架构实战营第五模块课后作业
云龙开炮版飞机大战(完整版)
Recommended model recurrence (I): familiar with torch rechub framework and use
[cloud native] 2.4 kubernetes core practice (middle)
How to install oracle19c in Centos8
测试--自动化测试:关于unittest框架
Recurrence of recommended models (III): recall models youtubednn and DSSM
《高难度谈话》突破谈话瓶颈,实现完美沟通
MIT线性代数中文笔记
Pygame 对图像进行翻转