完全二叉树(Complete Binary Tree)
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)的更多相关文章
- [Swift]LeetCode919. 完全二叉树插入器 | Complete Binary Tree Inserter
A complete binary tree is a binary tree in which every level, except possibly the last, is completel ...
- 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 ...
- [二叉树建树&完全二叉树判断] 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 ...
- 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 ...
- PAT甲级——1110 Complete Binary Tree (完全二叉树)
此文章同步发布在CSDN上:https://blog.csdn.net/weixin_44385565/article/details/90317830 1110 Complete Binary ...
- [LeetCode] 919. Complete Binary Tree Inserter 完全二叉树插入器
A complete binary tree is a binary tree in which every level, except possibly the last, is completel ...
- PAT1110:Complete Binary Tree
1110. Complete Binary Tree (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...
- A1110. Complete Binary Tree
Given a tree, you are supposed to tell if it is a complete binary tree. Input Specification: Each in ...
- PAT 甲级 1110 Complete Binary Tree
https://pintia.cn/problem-sets/994805342720868352/problems/994805359372255232 Given a tree, you are ...
- 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 ...
随机推荐
- Linux查看 kennel , 物理CPU个数、核数、逻辑CPU个数
other article on my list: 查看进程 https://i.cnblogs.com/PostDone.aspx?postid=9231604&actiontip=%E4% ...
- mongodb--win10安装
安装完成后再将安装后的bin目录加入PATH路径
- Linux文件查找命令find(转)
Linux find命令用来在指定目录下查找文件.任何位于参数之前的字符串都将被视为欲查找的目录名.如果使用该命令时,不设置任何参数,则find命令将在当前目录下查找子目录与文件.并且将查找到的子目录 ...
- faster-rcnn代码阅读1
毫无疑问,faster-rcnn是目标检测领域的一个里程碑式的算法.本文主要是本人阅读python版本的faster-rcnn代码的一个记录,算法的具体原理本文也会有介绍,但是为了对该算法有一个整体性 ...
- JVM基础(二) 实现自己的ClassLoader
为何要花时间实现自己的ClassLoader 尽管人生的乐趣非常大一部分来自于将时间花在有意思可是无意义的事情上,可是这件事绝对是有意思并且有意义的,有下面几个情景是值得我们花费时间实现自己的clas ...
- EditText焦点问题
1.在一个Activity中加入一个EditText后,每次进入这个Activity时输入法都会自己主动弹出来.非常烦,找了些资料,在此记下解决的方法: 方法:在EditText的父控件中获得焦点.这 ...
- Spring技术内幕:SpringIOC原理学习总结
前一段时候我把Spring技术内幕的关于IOC原理一章看完,感觉代码太多,不好掌握,我特意又各方搜集了一些关于IOC原理的资料,特加深一下印象,以便真正掌握IOC的原理. IOC的思想是:Spring ...
- Linux GDB程序调试工具使用简单介绍
GDB概述 GDB是GNU开源组织公布的一个强大的UNIX下的程序调试工具.也许,各位比較喜欢那种图形界面方式的,像VC.BCB等IDE的调试,但假设你是在UNIX平台下做软件,你会发现GDB这个调试 ...
- leetcode第一刷_Minimum Depth of Binary Tree
非常easy的题目.只是还是认为要说一下. 最小深度.非常快想到bfs,层序遍历嘛.本科的时候实在是没写过多少代码,一開始竟然想不到怎么保存一层的信息.后来想到能够压入一个特殊的对象,每次到达这个对象 ...
- 输入URL 一瞬间发生了什么
当你在浏览器中输入url后发生了什么?下面是个人学习过程中的总结,如有理解不正确或不足的地方希望大家指出.先上一张脑图: 还有个问题:www.baidu.com 键入后,域名怎么知道的是这个IP! 补 ...