当前位置:网站首页>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++;
}
}
边栏推荐
- 《乔布斯传》英文原著重点词汇笔记(五)【 chapter three 】
- 通过客户经理的开户二维码开股票账户安全吗?
- Oracle one line function Encyclopedia
- matplotlib matplotlib中plt.grid()
- matplotlib 简单逻辑回归可视化
- Jmeter接口测试,关联接口实现步骤(token)
- QSS buttons of different styles
- A game WP
- socket编程——poll模型
- Notes on key words in the original English work biography of jobs (VI) [chapter three]
猜你喜欢

(translation) the use of letter spacing to improve the readability of all capital text

C language: bubble sort

Jmeter接口测试,关联接口实现步骤(token)

自定义注解之编译时注解(RetentionPolicy.CLASS)
![[opencv] - Discrete Fourier transform](/img/03/10ce3d7c5d99ead944b2cae8d0cec0.png)
[opencv] - Discrete Fourier transform

compiling stm32f4xx_ it. c... “.\Objects\BH-F407.axf“ - 42 Error(s), 1 Warning(s).

Cassava tree disease recognition based on vgg16 image classification

How can games copied from other people's libraries be displayed in their own libraries

Prepare for the 1000 Android interview questions and answers that golden nine silver ten must ask in 2022, and completely solve the interview problems

Analysis on the bottom calling process of micro service calling component ribbon
随机推荐
[MySQL] understanding and use of indexes
JMeter interface test, associated interface implementation steps (token)
How to download the school logo, school name and corporate logo on a transparent background without matting
matplotlib 简单逻辑回归可视化
(translation) the use of letter spacing to improve the readability of all capital text
jmeter中csv参数化
On the underlying index principle of MySQL
Le labyrinthe des huit diagrammes de la bataille de cazy Chang'an
Notes on key words in the original English work biography of jobs (VI) [chapter three]
How safe is the new bond
Level 6 easy to mix words
Jmeter中的断言使用讲解
关掉一个线程
二、训练fashion_mnist数据集
Voiceprint Technology (VII): the future of voiceprint Technology
SQL高级
Is it safe to open an account at Huatai Securities?
[learn C from me and master the key to programming] insertion sort of eight sorts
C language: bubble sort
Matplotlib simple logistic regression visualization