完全二叉树(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 ...
随机推荐
- jquery源码分析(二)——架构设计
要学习一个库首先的理清它整体架构: 1.jQuery源码大致架构如下:(基于 jQuery 1.11 版本,共计8829行源码)(21,94) 定义了一些变量和函数jQu ...
- 学习EXTJS6(6)基本功能-工具栏和菜单
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- Windows 安装react native
1.下载node.js (https://nodejs.org/en/) 2.安装node.js,安装完成后按住 图标键+R ,输入CMD进入命令行终端,输入npm -v C:\Users\Admin ...
- 0614MySQL的InnoDB索引原理详解
转自http://www.cnblogs.com/shijingxiang/articles/4743324.html MySQL的InnoDB索引原理详解 http://www.admin10000 ...
- HDU 1238
好吧,这题直接搜索就可以了,不过要按照长度最短的来搜,很容易想得到. 记得ACM比赛上有这道题,呃..不过,直接搜..呵呵了,真不敢想. #include <iostream> #incl ...
- Openstack针对nova,cinder,glance使用ceph的虚拟机创建机制优化
今天在开源中国社区看到有例如以下一个问题: 已经成功把ceph作为cinder和 glance的后端,可是假设作为nova的后端,虚拟机启动速度非常慢,网上查了一下是由于openstack创建虚 ...
- 150723培训心得(queue)
queue(STL中函数,就是指队列) #include <iostream> #include <queue> using namespace std; //这 ...
- 时间格式字符串转化为date和时间戳
NSString *dateStr=@"2012-05-17 11:23:23"; NSLog(@"dateStr=%@",dateStr); NSDateFo ...
- NS3网络仿真(3): NetAnim
快乐虾 http://blog.csdn.net/lights_joy/ 欢迎转载,但请保留作者信息 在NS3提供的演示样例first.py中,并没有生成NetAnim所须要的xml文件,本节我们尝试 ...
- C语言数组和函数实例练习(二)
1.C语言中不允许函数的嵌套定义,但可以使用函数的嵌套调用. 例1:输入4个整数,找出其中最大的数. #include <stdio.h> #include <stdlib.h> ...