Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical an...
分类:
其他好文 时间:
2014-10-23 11:56:21
阅读次数:
221
数据源用数组混json结构,实现了基本的功能。效率一般,跟 dhtree 梅花雪树对比了下,都差不多。 (ps感觉比dhtree快点,跟梅花雪树差不多,个人测试)这个实现树的原理是根据json,不断的生成ul li, 下面是一个简单的例子(只有涉及到生成树,也就是说只是展示,tree类代码只有64行...
分类:
编程语言 时间:
2014-10-23 09:29:23
阅读次数:
286
how to build a ruby gem1. first you will creata a user in rubygem.org (https://rubygems.org/)2. create the directory structure like this:Java代码 $tree....
分类:
其他好文 时间:
2014-10-23 09:20:40
阅读次数:
136
题目来自LeetCode OJFor example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the following is not: 1 / \ 2 2 \ \ 3 ...
分类:
其他好文 时间:
2014-10-23 01:19:12
阅读次数:
99
我们可以通过预处理,在O(n)之内,算出f(1, i, a[i]) 定义数组为l[i], 算出f(j, n, a[j]) 定义数组为r[i]。
题目就转化为:求出 l[i] > r[j] (i < j)。
本质上,就是一个求逆序对的做法,用树状数组。...
分类:
其他好文 时间:
2014-10-23 00:09:08
阅读次数:
249
// -Operators can be roughly classified into three categories:// -Unary — Act on single operands// -Binary — Act on two operands// -Ternary — Act on t...
分类:
其他好文 时间:
2014-10-22 21:55:03
阅读次数:
222
ngx_radix_tree.h// 未被使用的节点#define NGX_RADIX_NO_VALUE (uintptr_t) -1typedef struct ngx_radix_node_s ngx_radix_node_t;struct ngx_radix_node_s { ng...
分类:
其他好文 时间:
2014-10-22 17:39:49
阅读次数:
208
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'It seems useful as a upgrade version of 'ls -R'
分类:
系统相关 时间:
2014-10-22 17:30:49
阅读次数:
221
动态规划(DP)似乎占据了大部分的编程竞赛题目,乃至三分之一。当然,DP也不是一个学一次就Ok的单一算法。
这还取决于你是否把数据结构与算法放在同一个等级中考虑。如果你想要在编程竞赛中一展风采的话,当然,有些数据结构是你应该熟悉的。其中最重要的有范围树(Range Tree,也被称为线段树或区间树)和树状数组(BITs),也被称作Fenwick树。除此之外,许多DP算法使用了一个前缀和数组(prefix sum array)。
能想到的最精华的单一算法如下所列,排名不分先后。绝大多数非动态规划问题似乎都...
分类:
编程语言 时间:
2014-10-22 15:56:48
阅读次数:
208
参考:http://www.geeksforgeeks.org/inorder-tree-traversal-without-recursion-and-without-stack/
1. Initialize current as root
2. While current is not NULL
If current does not have left child
a)...
分类:
其他好文 时间:
2014-10-22 14:38:08
阅读次数:
187