当前位置:网站首页>Creating a binary tree (binary linked list) from a generalized table
Creating a binary tree (binary linked list) from a generalized table
2022-06-25 09:24:00 【Building block mathematical modeling】
Generalized tables create binary trees ( Binary list
This paper is a non recursive method , Slightly more complicated
1. Note that the node is created first and then assigned , Avoid null pointer exceptions ( t->lc=new BiTNode; t=t->lc;
2.* Note that when creating a node, first assign its left and right subtrees to NULL
// Generalized tables create binary trees
void BTreeCreate(BT &t,char a[],int n)
{
SS S;
StackCreate(S);
int i=1,j;
t=new BiTNode;
t->data=a[0];
while(i<n)
{
if((a[i]=='(')&&Push(S,t))
{
j=1;
}
else if((a[i]==',')&&SVisit(S,t))
{
j=0;
}
else if((a[i]==')')&&Pop(S,t)) {
}
else if(a[i]=='#')
{
t=NULL;
}
else
{
if(j==1)
{
t->lc=new BiTNode;
t=t->lc;
t->lc=NULL;
t->rc=NULL;
t->data=a[i];
}
else if(j==0)
{
t->rc=new BiTNode;
t=t->rc;
t->lc=NULL;
t->rc=NULL;
t->data=a[i];
}
}
i++;
}
}
边栏推荐
- Atguigu---18-component
- How to download the school logo, school name and corporate logo on a transparent background without matting
- 《JVM》对象内存分配的TLAB机制与G1中的TLAB流程
- Notes on key words in the original English work biography of jobs (III) [chapter one]
- 微服务调用组件Ribbon底层调用流程分析
- Voiceprint Technology (V): voiceprint segmentation and clustering technology
- 2022 meisai question a idea sharing
- C language: find all integers that can divide y and are odd numbers, and put them in the array indicated by B in the order from small to large
- Analysis on the thinking of 2022 meisai C question
- Matplotlib decision boundary drawing function plot in Matplotlib_ decision_ Boundary and plt Detailed explanation of contour function
猜你喜欢
[opencv] - Discrete Fourier transform
matplotlib matplotlib中决策边界绘制函数plot_decision_boundary和plt.contourf函数详解
The meshgrid() function in numpy
The first techo day Tencent technology open day, 628 waiting for you!
5、 Project practice --- identifying man and horse
JMeter interface test, associated interface implementation steps (token)
Analysis on the bottom calling process of micro service calling component ribbon
WebGL谷歌提示内存不够(RuntimeError:memory access out of bounds,火狐提示索引超出界限(RuntimeError:index out of bounds)
Benefits and types of cloud network technology
compiling stm32f4xx_it.c... “.\Objects\BH-F407.axf“ - 42 Error(s), 1 Warning(s).
随机推荐
matplotlib matplotlib中plt.grid()
关掉一个线程
matplotlib matplotlib中决策边界绘制函数plot_decision_boundary和plt.contourf函数详解
Voiceprint Technology (II): Fundamentals of audio signal processing
[IOU] intersection over union
Summary of hardfault problem in RTOS multithreading
socket编程——poll模型
[final review notes] digital logic
Voiceprint Technology (I): the past and present life of voiceprint Technology
Are the top ten securities companies at great risk of opening accounts and safe and reliable?
从别人库里拷贝的游戏如何再自己的库里显示
Format analysis and explanation of wav file
matplotlib matplotlib中axvline()和axhline()函数
《乔布斯传》英文原著重点词汇笔记(二)【 chapter one】
Compare and explain common i/o models
Unity--configurable joint -- a simple tutorial to get you started with configurable joints
Lvs-dr mode single network segment case
WebGL发布之后不可以输入中文解决方案
Atguigu---01-scaffold
2、 Training fashion_ MNIST dataset