Date:2019-03-25 19:36:45

判断一棵树是否为完全二叉树

 #include <queue>
using namespace std;
void IsComplete(node* root)
{
queue<node*> q;
q.push(root);
while(!q.empty())
{
root = q.front();
q.pop();
if(root)
{
q.push(root->lchild);
q.push(root->rchild);
}
else
{
while(!q.empty())
{
root = q.front();
q.pop();
if(root)
{
printf("No\n");
return ;
}
}
}
}
printf("Yes\n");
}

完全二叉树(Complete Binary Tree)的更多相关文章

  1. [Swift]LeetCode919. 完全二叉树插入器 | Complete Binary Tree Inserter

    A complete binary tree is a binary tree in which every level, except possibly the last, is completel ...

  2. PAT A1110 Complete Binary Tree (25 分)——完全二叉树,字符串转数字

    Given a tree, you are supposed to tell if it is a complete binary tree. Input Specification: Each in ...

  3. [二叉树建树&完全二叉树判断] 1110. Complete Binary Tree (25)

    1110. Complete Binary Tree (25) Given a tree, you are supposed to tell if it is a complete binary tr ...

  4. PAT 1110 Complete Binary Tree[判断完全二叉树]

    1110 Complete Binary Tree(25 分) Given a tree, you are supposed to tell if it is a complete binary tr ...

  5. PAT甲级——1110 Complete Binary Tree (完全二叉树)

    此文章同步发布在CSDN上:https://blog.csdn.net/weixin_44385565/article/details/90317830   1110 Complete Binary ...

  6. [LeetCode] 919. Complete Binary Tree Inserter 完全二叉树插入器

    A complete binary tree is a binary tree in which every level, except possibly the last, is completel ...

  7. PAT1110:Complete Binary Tree

    1110. Complete Binary Tree (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...

  8. A1110. Complete Binary Tree

    Given a tree, you are supposed to tell if it is a complete binary tree. Input Specification: Each in ...

  9. PAT 甲级 1110 Complete Binary Tree

    https://pintia.cn/problem-sets/994805342720868352/problems/994805359372255232 Given a tree, you are ...

  10. 1110 Complete Binary Tree (25 分)

    1110 Complete Binary Tree (25 分) Given a tree, you are supposed to tell if it is a complete binary t ...

随机推荐

  1. 奇妙的go语言(基本的语法)

    [ 声明:版权全部,欢迎转载,请勿用于商业用途.  联系信箱:feixiaoxing @163.com] 学习一门新的语言无非就是从主要的语法開始的.通过语法书来学习语言毕竟是很枯燥的,所以我们最好还 ...

  2. HDU 1912

    坑,直接把公路看成X轴来做,然后,排序扫描一下,你懂的. #include <iostream> #include <algorithm> #include <cstdi ...

  3. hdu 4704 Sum (整数和分解+高速幂+费马小定理降幂)

    题意: 给n(1<n<),求(s1+s2+s3+...+sn)mod(1e9+7). 当中si表示n由i个数相加而成的种数,如n=4,则s1=1,s2=3.                 ...

  4. java中byte类型

    http://www.cnblogs.com/Robotke1/archive/2013/05/25/3099309.html ------------------------------------ ...

  5. Coco2d-js/Cocos2d-html5中Android返回键实现

    导语: 首先Cocos2d-x其中实现Menu和Back按键相对简单一点,而在资源较少的Cocos2d-html5其中.要实现返回还是有一点不一样的,并且有没有详细的demo.也就仅仅有自己去看api ...

  6. redis之Hash存储与String存储内存消耗对照

    存储对象User String存储方式: SET media:1155315 939 GET media:1155315 > 939 String结构存储该对象 User243 243600 存 ...

  7. 【SDOI 2008】 仪仗队

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=2190 [算法] 同POJ3090 值得注意的是此题数据规模较大,建议使用用线性筛筛出 ...

  8. BZOJ-4706 B君的多边形 OEIS

    题面 题意:有一个正n多边形,我们要连接一些对角线,把这个多边形分成若干个区域,要求连接的对角线不能相交,每个点可以连出也可以不连出对角线,即最终不要求所有区域均为三角形,问总方案数mod (10^9 ...

  9. Nginx介绍及知识点(摘抄)

    正向代理是把自己的网络环境切换成代理的网络 反向代理是代理机器返回给我要我的资源 本文借鉴参考于http://tengine.taobao.org/book/chapter_02.html. 属于纯干 ...

  10. Intel VTune Amplifier XE 使用

    VTune <VTune 开发者手册> 1. 安装 1.1 软件安装 下载: (安装包下载地址) 安装: # 1.解压 tar -zxvf filename.tar.gz # 2.安装 c ...