当前位置:网站首页>2023 Wangdao C language training camp (clue binary tree)
2023 Wangdao C language training camp (clue binary tree)
2022-06-10 10:25:00 【Blizzard front end】
Clue binary tree
( It is absolutely impossible to solve a big problem , It is of no use in industry )
When the left child pointer or right child pointer of a node is empty , The clue binary tree is to prevent the left and right child pointers of the node from being empty 



The header file
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
Structure
typedef char ElemType;
typedef struct ThreadNode {
ElemType data;
struct ThreadNode* lchild, * rchild;
int ltag, rtag;
}ThreadNode,*ThreadTree;
Main function
// Build a clue tree by hand , in total 5 Nodes
void BulidThreadTree(ThreadTree& T)
{
ThreadTree arr[5];
int i;
for (i = 0; i < 5; i++)
{
arr[i] = (ThreadTree)malloc(sizeof(ThreadNode));
//memset It's an initialization function , The function is to set all in a block of memory to the specified value .
memset(arr[i], 0, sizeof(ThreadNode));
arr[i]->data = 'A' + i;
}
arr[0]->lchild = arr[1];
arr[0]->rchild = arr[2];
arr[1]->lchild = arr[3];
arr[2]->lchild = arr[4];
T = arr[0];
}
void InThread(ThreadTree& p, ThreadTree& pre)
{
if (p != NULL)
{
//
InThread(p->lchild, pre);
if (p->lchild == NULL)// On the left for NULL
{
p->lchild = pre;
p->ltag = 1;
}
if (pre != NULL && pre->rchild == NULL)
{
//pre The right child of the node is NULL, Let it point to the successor node
pre->rchild = p;
pre->rtag = 1;
}
pre = p;
InThread(p->rchild, pre);
}
}
void CreateInThread(ThreadTree T)
{
ThreadTree pre = NULL;// Use auxiliary pointer
if (T != NULL)
{
InThread(T, pre);
pre->rchild = NULL;
pre->rtag = 1;
}
}
// The first node under middle order traversal
ThreadNode* Firstnode(ThreadNode* p)
{
while (p->ltag == 0)
p = p->lchild;
return p;
}
The main function
int main()
{
ThreadTree T;
ThreadTree p;
BulidThreadTree(T);
CreateInThread(T);// Construct a clue binary tree
p = Firstnode(T);
printf(" The value of the leftmost lower node is :%c\n", p->data);
system("pause");
}

边栏推荐
- [497. random points in non overlapping rectangles]
- [interesting reading] deepinf: social influence prediction with deep learning
- 【GoLang】通过BMI指数学习控制台输入与条件控制
- Xcode8.3.2 automatic packaging script
- Matlab绘制曲线
- Notes to docker advanced (6) master-slave replication of MySQL in docker
- 12892. 子数整数(OJ,入门)
- “大写意花鸟画宗师李苦禅先生”重磅数字藏品全网首发
- Eg2131 test circuit
- 山东大学软件学院项目实训-创新实训-网络安全靶场实验平台(十七)
猜你喜欢

Notes to docker advanced chapter (7) steps to build a redis three master and three slave cluster case in docker

fastadmin使用PHPExcel导出表格数据到Excel中

Important technological breakthrough in privacy computing! 100 million level data density analysis can be completed in 10 minutes

Bing's website search site: < domain name>< search content>

隐私计算重要技术突破!亿级数据密态分析可在10分钟内完成

Xcode8.3.2 automatic packaging script

MongoDB 发布“可查询加密”系统 Queryable Encryption

axure添加下拉菜单联动

微软再曝“丑闻”:在办公室看 VR 黄片,“HoloLens 之父”即将离职!
![[497. random points in non overlapping rectangles]](/img/c7/5e3e7bf1a78332aff4d2d42d6f826e.png)
[497. random points in non overlapping rectangles]
随机推荐
2022年金属非金属矿山提升机操作考试题库及答案
Print: Entry, ':CFBundleIdentifier', Does Not Exist
Definition and use of the apipost environment variable
使用 nsenter 进入 netns 抓包
张小白教你使用OGG实现Oracle 19C到MySQL 5.7的数据同步(1)
Market development details of NFT casting trading platform
Microsoft exposes another "scandal": watching VR porn in the office, "the father of hololens" is about to leave!
[model basis] RNN | LSTM
ApiPost的环境变量的定义和使用「ApiPost环境变量」
osg基本操作
MySQL——操作数据库
8、 Chain mode
Uncaught TypeError: Cannot read properties of undefined (reading ‘colspan‘)
六、观察者模式
金融风控实战——异常检测(一)
fastadmin使用PHPExcel导出表格数据到Excel中
“会说话的汤姆猫家族-时代逐光者”3D数字藏品中奖名单公布
Some problems in using message queue service in thinkphp6
MongoDB 发布“可查询加密”系统 Queryable Encryption
【GoLang】通过BMI指数学习控制台输入与条件控制