Given a binary tree, determine if it is
height-balanced.For this problem, a height-balanced binary tree is defined as a
binary tree in which the depth...
分类:
其他好文 时间:
2014-05-19 20:40:55
阅读次数:
278
题目链接:HDU 2795 Billboard【题意】给你一张h*w(1 7 #include
8 #include 9 using namespace std;10 const int MAX = 200005;11 12 int tree[MAX=
val)26 {27 ...
分类:
其他好文 时间:
2014-05-19 10:09:17
阅读次数:
419
Given a binary tree, determine if it is a valid
binary search tree (BST).Assume a BST is defined as follows:The left subtree of
a node contains only n...
分类:
其他好文 时间:
2014-05-19 07:23:48
阅读次数:
357
伸展树概念 伸展树(Splay Tree)是一种二叉排序树,它能在O(log
n)内完成插入、查找和删除操作。它由Daniel Sleator和Robert Tarjan创造。 (01)
伸展树属于二叉查找树,即它具有和二叉查找树一样的性质:假设x为树中的任意一个结点,x节点包含关键字key,节点x...
分类:
其他好文 时间:
2014-05-18 19:17:30
阅读次数:
225
Two elements of a binary search tree (BST) are
swapped by mistake.Recover the tree without changing its structure.Note:A
solution using O(n) space is ...
分类:
其他好文 时间:
2014-05-17 14:45:17
阅读次数:
290
第四道树题,逐渐能写递归了。虽然最后AC的代码还是看了网络,但是距离成功攻克此类问题仅一步之遥。题目:一棵树,判断是否为AVL。(AVL条件:树上任意一点的左右子树的高度差_
1 ) return false; else return isBalanced(root.lef...
分类:
其他好文 时间:
2014-05-16 04:04:41
阅读次数:
259
安装软件[root@kvm ~]#yum grouplist Virtualization
Virtualization Client Virtualization Platform Virtualization
Toolscentos6.4-minimal-64bit 默认是200个包...
分类:
系统相关 时间:
2014-05-16 00:44:09
阅读次数:
618
原题:
题目解析:这个问题的实质是要我们按成访问二叉树的结点,并返回每层访问的结果,这里要求走Z字,其实就是一行正向一行反向。
/*
the kernel idea is visit a binary search tree in level and
the additional work we have to label the end of one level.
*/
v...
分类:
其他好文 时间:
2014-05-15 23:18:46
阅读次数:
515
裸题,瞬秒。。
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define L(id) tree[id].ch[0]
#define R(id) tree[id].ch[1]
#define Size(id) tree[id].size
#...
分类:
其他好文 时间:
2014-05-15 22:52:51
阅读次数:
328
第五道树题,10分钟之内一遍AC。做树题越来越有feel~题目:求一棵树从root结点到叶子结点的最短路径。思路:仍然是递归。如果一个结点的左右子树任意一边为Null,该子树的minDepth应为非null子树的高度+1;如果一个结点的左右子树两边都非Null,则该子树的minDepth应为两个子树...
分类:
其他好文 时间:
2014-05-15 17:24:43
阅读次数:
226