当前位置:网站首页>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;
}
边栏推荐
- 535. encryption and decryption of tinyurl: design a URL simplification system
- Recommended model recurrence (I): familiar with torch rechub framework and use
- 高校如何基于云原生构建面向未来的智慧校园?全栈云原生架构VS传统IT架构
- 面试突击61:说一下MySQL事务隔离级别?
- JVM之方法区
- 1. Opencv实现简单颜色识别
- C#实现图的邻接矩阵和邻接表结构
- 推荐模型复现(二):精排模型DeepFM、DIN
- Newton inequality
- Kyligence Zen, an intelligent indicator driven management and decision-making platform, is newly launched and is in limited internal testing
猜你喜欢

Method area of JVM

Cache consistency, delete cache, write cache, cache breakdown, cache penetration, cache avalanche

中职网络安全技能竞赛之应用服务漏洞扫描与利用(SSH私钥泄露)

Principle and process of MySQL master-slave replication

超 Nice 的表格响应式布局小技巧

对p值的理解

参加2022年杭州站Cocos Star Meetings
![[intelligent QBD risk assessment tool] Shanghai daoning brings you leanqbd introduction, trial and tutorial](/img/00/9a6d17844b88f6921ad488f4975684.png)
[intelligent QBD risk assessment tool] Shanghai daoning brings you leanqbd introduction, trial and tutorial

面试突击61:说一下MySQL事务隔离级别?

Comment calculer Win / Tai / Loss in paired t - test
随机推荐
Bison uses error loop records
MySQL主从同步之 异步复制 半同步复制 全同步复制
在印度与软件相关的发明可不可以申请专利?
Gbase8s database select has order by Clause 2
【智能QbD风险评估工具】上海道宁为您带来LeanQbD介绍、试用、教程
MFC-对话框程序核心-IsDialogMessage函数-MSG 消息结构-GetMessage函数-DispatchMessage函数
如何計算win/tai/loss in paired t-test
How to calculate win/tai/loss in paired t-test
Problem solving: modulenotfounderror: no module named 'pip‘
Qt的信号与槽
Gbase8s database select has order by Clause 6
How to create new user for ORACLE 19c (CDB & PDB)
How to install oracle19c in Centos8
Cache consistency, delete cache, write cache, cache breakdown, cache penetration, cache avalanche
Gbase8s database into temp clause creates a temporary table to save query results.
Syntax of gbase8s database incompatible with for update clause
Earth observation satellite data
深入理解 volatile 关键字
参加2022年杭州站Cocos Star Meetings
oracle 19c : change the user sys/system username pasword under Linux