二cha树
void porder(BTree *b)
{
BTree *St[MaxSize],*p;
int top=;
if(b!=NULL)
{
top++;
St[top]=b;
while(top>-)
{
p=St[top];
top--;
printf("%c",p->data);
if(p->rchild!=NULL)
{
top++;
St[top]=p->rchild;
}
if(p->lchild!=NULL)
{
top++;
St[top]=p->lchild;
}
}
}
} void psorder(BTree*t)
{
BTree *St[MaxSize];
BTree*p;
int flag,top=-;
do
{
while(t)
{
top++;
St[top]=t;
t=t->lchild;
}
p=NULL;
flag=;
while(top!=-&&flag)
{
t=St[top];
if(t->rchild==p)
{
printf("%c ",t->data);
top--;
p=t;
}
else
{
t=t->rchild;
flag=;
}
}
}while(top!=-)
} int level(BTree *b,ElemType x,int h)
{
int h1;
if(b==NULL)
return();
else
if(b->data==x)
return(h);
else
{
h1=level(b->lchild,x,h+);
if(h1!=)
return(h1);
else
return level(b->rchild,x,h+);
}
} void translevel(BTree *b)
{
struct node
{
BTree *vec[MaxSize];
int f,r;
}Qu;
Qu.f=;
Qu.r=;
if(b!=NULL)
printf("%c ",b->data);
Qu.vec[Qu.r]=b;
Qu.r=Qu.r+;
while(Qu.f<Qu.r)
{
b=Qu.vec[Qu.f];
Qu.f=Qu.f+;
if(b->lchild!=NULL)
{
printf("%c",b->lchild->data);
Qu.vec[Qu.r]=b->lchild;
Qu.r=Qu.r+;
}
if(b->rchild!=NULL)
{
printf("%c ",b->rchild->data);
Qu.vec[Qu.r]=b->rchild;
Qu.r=Qu.r+;
}
}
printf("\n");
}
二cha树的更多相关文章
- 二维树状数组 BZOJ 1452 [JSOI2009]Count
题目链接 裸二维树状数组 #include <bits/stdc++.h> const int N = 305; struct BIT_2D { int c[105][N][N], n, ...
- HDU1559 最大子矩阵 (二维树状数组)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1559 最大子矩阵 Time Limit: 30000/10000 MS (Java/Others) ...
- [.net 面向对象程序设计进阶] (6) Lamda表达式(二) 表达式树快速入门
[.net 面向对象程序设计进阶] (6) Lamda表达式(二) 表达式树快速入门 本节导读: 认识表达式树(Expression Tree),学习使用Lambda创建表达式树,解析表达式树. 学习 ...
- POJMatrix(二维树状数组)
Matrix Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 22058 Accepted: 8219 Descripti ...
- poj 1195:Mobile phones(二维树状数组,矩阵求和)
Mobile phones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 14489 Accepted: 6735 De ...
- Codeforces Round #198 (Div. 1) D. Iahub and Xors 二维树状数组*
D. Iahub and Xors Iahub does not like background stories, so he'll tell you exactly what this prob ...
- POJ 2155 Matrix(二维树状数组+区间更新单点求和)
题意:给你一个n*n的全0矩阵,每次有两个操作: C x1 y1 x2 y2:将(x1,y1)到(x2,y2)的矩阵全部值求反 Q x y:求出(x,y)位置的值 树状数组标准是求单点更新区间求和,但 ...
- [poj2155]Matrix(二维树状数组)
Matrix Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 25004 Accepted: 9261 Descripti ...
- POJ 2155 Matrix (二维树状数组)
Matrix Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 17224 Accepted: 6460 Descripti ...
随机推荐
- Linux内核配置浅析
1.Linux Kernel Kconfig系统的基本结构 Linux内核的配置系统由三个部分组成,分别是: 1>.Makefile:分布在 Linux 内核源代码根目录及各层目录中,定义 Li ...
- 【转】安卓Fragment不完全介绍
转两篇博客: 1.http://blog.csdn.net/lmj623565791/article/details/37970961 2.http://blog.csdn.net/lmj623565 ...
- 今天学习了下,如何破解wifi
破解了隔壁的wif,得罪了,哥哥要蹭网一段时间. 主要思路:安装linux环境.这里我选择了虚拟机加cdlinux .运行里面的min抓得握手包,然后淘宝花10元跑下包,因为自己的电脑不行,跑费时间太 ...
- My数据库和Ms数据库的区别
mssql 是微软的那个 SQL Server,运行于windows2000,2003等平台 mysql 是由瑞典mySQL AB 公司开发,目前属于Oracle旗下公司.可运行在windows平台. ...
- Memcached操作以及用法
Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的速度.Memcached ...
- MYSQL 函数复习
数学函数 ABS(X) 返回X的绝对值 SQRT(x) 返回非负数X的二次方根 MOD(x,y) 返回x被y除后的余数 CEIL(x) ...
- WCF服务发布到IIS中去 在WCF调试
第一个WCF程序 1. 新建立空白解决方案,并在解决方案中新建项目,项目类型为:WCF服务应用程序.建立完成后如下图所示: 2.删除系统生成的两个文件IService1.cs与Service1.svc ...
- 如何设置secureCRT的鼠标右键为弹出文本操作菜单功能
secureCRT的鼠标右键功能默认是粘贴的功能,用起来和windows系统的风格不一致, 如果要改为右键为弹出文本操作菜单功能,方便对选择的内容做拷贝编辑操作,可以在 options菜单----&g ...
- 使用AngularJS的三个重要原因
入门教程:http://www.ituring.com.cn/minibook/303 : http://angularjs.cn/tag/AngularJS 原因一:Google开发的框架 要知道开 ...
- 小兔JS教程(五) 简单易懂的JSON入门
上一节的参考答案: http://xiaotublog.com/demo.html?path=homework/04/index2 本节重点来介绍一下JSON,JSON(JavaScript Obje ...