Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe...
分类:
其他好文 时间:
2014-07-07 23:09:49
阅读次数:
298
Item2:尽量以const,enum,inline替换#define原因:1, #define ASPECT_RATIO 1.63 编译错误时产生魔数,应以const double Aspect_Ratio = 1.63替换 2, #define不能提供作用域,如某个类的常量 ...
分类:
编程语言 时间:
2014-07-07 21:32:51
阅读次数:
235
二叉树的前序遍历:root点先被访问,然后是left和right子节点。迭代的版本也相对好写。1、递归版本:时间复杂度O(N),空间复杂度O(N) 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int va...
分类:
其他好文 时间:
2014-07-07 20:35:24
阅读次数:
158
二叉树的中序遍历1、递归版本/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) :...
分类:
其他好文 时间:
2014-07-07 20:00:20
阅读次数:
161
Problem Description: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 equ...
分类:
其他好文 时间:
2014-07-07 19:03:39
阅读次数:
165
Problem Description:Given a binary tree, flatten it to a linked list in-place.Solution:对二叉树进行前序遍历(pre-order). 1 public void flatten(TreeNode root) { 2...
分类:
其他好文 时间:
2014-07-07 18:47:24
阅读次数:
306
二叉树的后续遍历1、递归版本/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) :...
分类:
其他好文 时间:
2014-06-30 14:17:28
阅读次数:
306
为什么选择跳表目前经常使用的平衡数据结构有:B树,红黑树,AVL树,Splay Tree, Treep等。想象一下,给你一张草稿纸,一只笔,一个编辑器,你能立即实现一颗红黑树,或者AVL树出来吗? 很难吧,这需要时间,要考虑很多细节,要参考一堆算法与数据结构之类的树,还要参考网上的代码,相当麻烦。用...
分类:
其他好文 时间:
2014-06-30 12:39:53
阅读次数:
257
本节讲述内存中LevelDB的数据结构Memtable,Memtable义如其名即为内存中的KV Table,即LSM-Tree中的C0 Tree。我们知道在LSM-Tree中刚插入的的KV数据都是存储在内存中,当内存中存储的数据超过一定量以后再写到磁盘中。而对于leveldb来说这个过程演变为内存...
分类:
数据库 时间:
2014-06-30 11:28:07
阅读次数:
295
http://www.ilsistemista.net/index.php/virtualization/43-kvm-scalability-and-consolidation-ratio-cache-none-vs-cache-writeback.html?limitstart=0 In the...
分类:
其他好文 时间:
2014-06-29 19:37:42
阅读次数:
265