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树的更多相关文章

  1. 二维树状数组 BZOJ 1452 [JSOI2009]Count

    题目链接 裸二维树状数组 #include <bits/stdc++.h> const int N = 305; struct BIT_2D { int c[105][N][N], n, ...

  2. HDU1559 最大子矩阵 (二维树状数组)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1559 最大子矩阵 Time Limit: 30000/10000 MS (Java/Others)  ...

  3. [.net 面向对象程序设计进阶] (6) Lamda表达式(二) 表达式树快速入门

    [.net 面向对象程序设计进阶] (6) Lamda表达式(二) 表达式树快速入门 本节导读: 认识表达式树(Expression Tree),学习使用Lambda创建表达式树,解析表达式树. 学习 ...

  4. POJMatrix(二维树状数组)

    Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 22058   Accepted: 8219 Descripti ...

  5. poj 1195:Mobile phones(二维树状数组,矩阵求和)

    Mobile phones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 14489   Accepted: 6735 De ...

  6. 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 ...

  7. POJ 2155 Matrix(二维树状数组+区间更新单点求和)

    题意:给你一个n*n的全0矩阵,每次有两个操作: C x1 y1 x2 y2:将(x1,y1)到(x2,y2)的矩阵全部值求反 Q x y:求出(x,y)位置的值 树状数组标准是求单点更新区间求和,但 ...

  8. [poj2155]Matrix(二维树状数组)

    Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 25004   Accepted: 9261 Descripti ...

  9. POJ 2155 Matrix (二维树状数组)

    Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 17224   Accepted: 6460 Descripti ...

随机推荐

  1. X-001 FriendlyARM Tiny4412 uboot移植前奏

    版权声明:本文为博主原创文章,转载请注明出处 开发环境:win7 64位 + VMware12 + Ubuntu14.04 64位 工具链:linaro提供的gcc-linaro-6.1.1-2016 ...

  2. listen函数里面backlog的意义以及各种情况

    先看了这篇: http://www.cppblog.com/thisisbin/archive/2010/02/07/107444.html 里面说了会维护两个队列,established 和 syn ...

  3. Hibernate 继承表结构

    有Product , Book ,Clothes三张表 Product:id,name Book: id ,name,pageCount Clothes: id ,name ,size 创建三张表 产 ...

  4. A股暴跌三日市值蒸发4.2万亿 股民人均浮亏超2万

    A股暴跌三日市值蒸发4.2万亿 股民人均浮亏超2万 http://finance.qq.com/a/20150508/010324.htm?pgv_ref=aio2015&ptlang=205 ...

  5. FB面经 Prepare: All Palindromic Substrings

    Given a string, calculate how many substring is palindrome. Ignore non-char characters. Ignore case; ...

  6. IOS开发之按钮控件Button详解

    reference:http://mxcvns.lofter.com/post/1d23b1a3_685d59d 首先是继承问题,UIButton继承于UIControl,而UIControl继承于U ...

  7. PHP下的命令行执行

    PHP 的命令行模式 以下是 PHP 二进制文件(即 php.exe 程序)提供的命令行模式的选项参数,您随时可以通过 PHP -h 命令来查询这些参数. Usage: php [options] [ ...

  8. JS 中 Class - 类创建

    Class - 类创建 Class类实现了在JavaScript中声明一个新的类, 并通过构造函数实例化这个类的机制.通过使用Class.create()方法, 你实际上声明了一个新的类, 并定义了一 ...

  9. Bzoj3756

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3756 题解:乱搞 代码: #include<iostream> #include ...

  10. Spark调优与调试

    1.使用SparkConf配置Spark (1)在java中使用SparkConf创建一个应用: SparkConf conf =;i++){ javaBean bean =new javaBean( ...