Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
点击打开原题链接
这个题剑指offer里也有,简单的递归即可,代码很清晰:...
分类:
其他好文 时间:
2014-10-05 22:56:09
阅读次数:
185
题意:给你一颗带边权树,问你其中 dis(v,u) 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 #include 14 #include 15 #include 16 ...
分类:
其他好文 时间:
2014-10-05 21:05:48
阅读次数:
221
1红黑树简介
先来看下算法导论对R-B Tree的介绍:
红黑树,一种二叉查找树,但在每个结点上增加一个存储位表示结点的颜色,可以是Red或Black。
通过对任何一条从根到叶子的路径上各个结点着色方式的限制,红黑树确保没有一条路径会比其他路径长出俩倍,因而是接近平的。
红黑树,作为一棵二叉查找树,满足二叉查找树的一般性质。下面,来了解下 二叉查找树的一般性质。
二叉查找树
二叉查找树...
分类:
其他好文 时间:
2014-10-05 19:24:38
阅读次数:
216
Code path:
https://github.com/bluesilence/Lisp/tree/master/clojure/projects/room-escape
As I have been a fan of room-escape games, there have always been a desire to make my own story of a roo...
分类:
Web程序 时间:
2014-10-05 17:44:38
阅读次数:
269
四边形优化DPTree ConstructionTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 868Accepted Submission(s):...
分类:
其他好文 时间:
2014-10-05 17:22:48
阅读次数:
132
Time Limit:1000MSMemory Limit:65536KTotal Submissions:2292Accepted:878DescriptionA tree (i.e. a connected graph without cycles) with vertices numbered...
分类:
其他好文 时间:
2014-10-05 16:49:58
阅读次数:
154
题目大意:在二维平面上找出一个点,使它到所有给定点的距离和最小,距离定义为欧氏距离,求这个最小的距离和是多少(结果需要四舍五入)?思路:如果不能加点,问所有点距离和的最小值那就是经典的MST,如果只可以加一个点问最小值就是广义的费马点的问题,如果加点的数目不加限制,那问题就成了斯坦纳树的问题(介个属...
分类:
其他好文 时间:
2014-10-05 16:19:58
阅读次数:
211
题目大意:一棵树(不一定是二叉树!!),树的节点上本来都有一个苹果,要求完成以下操作:1.指定某个节点,如果这个节点原本有苹果则拿去,如果没有苹果则填上一个苹果2.询问某个节点以及其子树一共有多少个苹果思路:dfs这棵树,记录下第一次到达这个节点的时间以及遍历离开的时间,于是一个节点就成了一个区间,...
分类:
移动开发 时间:
2014-10-05 15:59:58
阅读次数:
160
#include
#include
#include
using namespace std;
#define SIZE 230
#define BACK 1
#define AWAY 0
int DP[SIZE][SIZE][2];
bool visits[SIZE];
int vals[SIZE];
deque tree[SIZE];
int num, steps;
void ...
分类:
移动开发 时间:
2014-10-05 15:08:08
阅读次数:
176