Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2...
分类:
编程语言 时间:
2014-07-12 13:13:24
阅读次数:
195
原来join=inner join,left/right/full join=left/right/full outer join。join/inner join仅返回匹配的left outer join返回左边每一项,右边不匹配的就null,right反之full outer join返回左右的,...
分类:
数据库 时间:
2014-07-12 12:54:23
阅读次数:
234
语言:Python描述:使用递归实现 1 class Solution: 2 # @return an integer 3 def numTrees(self, n): 4 if n == 0: 5 return 0 6 eli...
分类:
其他好文 时间:
2014-07-11 23:44:08
阅读次数:
216
Erlang系统自带的基础数据类型有:atom、tuple、list、binary、pid、float、number、port、reference、record。用户可以通过通过命令type来自定义数据类型,实现方法:-type device() :: atom() | pid().-type pr...
分类:
其他好文 时间:
2014-07-11 23:26:47
阅读次数:
507
http://blog.csdn.net/angus_17/article/details/8493448binary 二进制,数据流,也可以转化成 1100011类似的protobuf 是google的,二进制的数据传输协议,性能比 xml 和 json 号。 但 可读性 差Thrift 是 Fa...
分类:
Web程序 时间:
2014-07-11 21:30:15
阅读次数:
295
参考资料:红黑树我的实现 1 #define BLACK 1 2 #define RED 0 3 4 struct node 5 { 6 int value; 7 node *left, *right, *parent; 8 bool color; 9 ...
分类:
其他好文 时间:
2014-07-09 13:37:56
阅读次数:
144
二叉排序树(Binary Sort Tree):或者是一颗空树,或者是具有以下性质的树:(1)若它的左子树不空,则左子树上所以结点的值均小于它的根节点的值;(2)若它的右子树不空,则右子树上的所以结点的值均大于它的根节点的值;(3)它的左、右子树也分别是二叉排序树。
二叉排序树的基本操作均可以在O(h)时间内完成(算法导论p165)。
相关操作代码如下:
int InsertBST(BiTr...
分类:
其他好文 时间:
2014-07-09 13:12:09
阅读次数:
160
模板
题意:给你一个图,1总是为根,每个边有单位价值,每个点有权重。
每条边的价值 = sum(后继节点权重)*边的单位价值。
求树的最小价值,即构成一棵树的n-1条边的最小价值。
算法:
1、因为每个边的价值都要乘以后来访问的节点的权重,而走到后来访问的点必经过这条边。
实际上总价值就是 到每个点的最短路径*这个点的权重。
2、但是这个题 数据量真的太大了,50000个点...
分类:
其他好文 时间:
2014-07-09 11:33:57
阅读次数:
273
题目
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.
For example:
Given the below binary tree ...
分类:
其他好文 时间:
2014-07-09 10:32:42
阅读次数:
151
这个点POJ挂了,代码没法提交,先存到这里,明天再提交试试看。
//#define DEBUG
#include
#define maxn 100002
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
__int64 tree[maxn << 2], arr[maxn], lazy[maxn << 2];...
分类:
其他好文 时间:
2014-07-09 09:41:55
阅读次数:
213