二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 ...
随机推荐
- BZOJ 1101 [POI2007]Zap ——Dirichlet积
[题目分析] Dirichlet积+莫比乌斯函数. 对于莫比乌斯函数直接筛出处理前缀和. 对于后面向下取整的部分,可以分成sqrt(n)+sqrt(m)部分分别计算 学习了一下线性筛法. 积性函数可以 ...
- 【转】国外程序员整理的Java资源大全
Java几乎是许多程序员们的入门语言,并且也是世界上非常流行的编程语言.国外程序员Andreas Kull在其Github上整理了非常优秀的Java开发资源,推荐给大家.译文由ImportNew- 唐 ...
- UVa 10653 - Bombs! NO they are Mines!!
题目大意:给你一个二维迷宫,给定入口和出口,找出最短路径. 无权图上的单源最短路,用BFS解决. #include <cstdio> #include <queue> #inc ...
- [Angular Tutorial] 11 -Custom Filters
在这一步中您将学到如何创建您自己的展示过滤器. ·在先前的步骤中,细节页面展示“true”或“false”来显示某部电话是否有某项功能.在这一步中,我们将使用自定义的过滤器来将这些个字符串转化成符号: ...
- java爬虫技术
原博:http://983836259.blog.51cto.com/7311475/1730243 开源爬虫分类: 1.分布式爬虫:Nutch 2.JAVA单机爬虫:Crawler4j.WebMag ...
- UITableView 之 取消选中
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [table ...
- ubuntu16.04 安装搜狗输入法
刚刚升级ubuntu16.04LTS,安装搜狗输入法又出问题. 和以前一样,在官网下了deb包,直接双击安装,打开了Software Center(如下:改版过了,但是看起来是没有安装上的),点Ins ...
- Quartz2D 之 简单使用
1. 获取Graphics Context CGContextRef ctx = UIGraphicsGetCurrentContext(); 2. 最后的渲染接口 CGContextStrokePa ...
- mySQL内存及虚拟内存优化设置
为了装mysql环境测试,装上后发现启动后mysql占用了很大的虚拟内存,达8百多兆.网上搜索了一下,得到高人指点my.ini.再也没见再详细的了..只好打开my.ini逐行的啃,虽然英文差了点,不过 ...
- jQuery attr removeAttr 属性操作
jQuery attr removeAttr 属性操作 <%@ page language="java" import="java.util.*" pag ...