语言:Python描述:使用递归实现 1 # Definition for a binary tree node 2 # class TreeNode: 3 # def __init__(self, x): 4 # self.val = x 5 # self...
分类:
其他好文 时间:
2014-07-09 20:46:34
阅读次数:
168
二叉排序树(Binary Sort Tree):或者是一颗空树,或者是具有以下性质的树:(1)若它的左子树不空,则左子树上所以结点的值均小于它的根节点的值;(2)若它的右子树不空,则右子树上的所以结点的值均大于它的根节点的值;(3)它的左、右子树也分别是二叉排序树。
二叉排序树的基本操作均可以在O(h)时间内完成(算法导论p165)。
相关操作代码如下:
int InsertBST(BiTr...
分类:
其他好文 时间:
2014-07-09 13:12:09
阅读次数:
160
题目
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent
a number.
An example is the root-to-leaf path 1->2->3 which represents the number 123.
Find ...
分类:
其他好文 时间:
2014-07-08 21:43:08
阅读次数:
219
不同进制的书写方式
八进制(Octal) 0o377十六进制(Hex) 0xFF二进制(Binary) 0b11111111
不同进制之间的转换
python提供了三个内置的函数,可以用来在不同进制间做转换。
>>> oct(255), hex(255), bin(255)
('0o377', '0xff', '0b11111111')
还可以使用int函数,把字符串转成数值
>...
分类:
编程语言 时间:
2014-07-08 20:53:09
阅读次数:
195
地形元素
一般情况下,为了使游戏更具有美观性,会在游戏地形上放置很多的元素,这些元素是与地形分开的。主要包括:树木,草地,自定义网格模型。
树元素
首先导入系统提供的树木标准资源包,在project视图中,点击鼠标右键,然后从菜单中选择import-----tree creator。接着在地形菜单里点击第五个按钮,添加树模型。然后点击edit trees按钮,将弹出如下列表:...
分类:
其他好文 时间:
2014-07-08 18:24:33
阅读次数:
266
Mozilla工程师通过优化Static Initializer(静态初始化,或全局建构函数, Global Constructor)和Binary布局来提升FireFox启动速度的文章,非常有参考价值。文章中以x86及x86-64平台为基础,下面加了Mac OS及Android上的binary布局。什么是Static Initializer? 简而言之就是全局C++对象的初始化。...
分类:
其他好文 时间:
2014-07-08 17:55:40
阅读次数:
278
Unique Binary Search Trees
My Submissions
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?
For example,
Given n = 3, there are a total of 5 uniqu...
分类:
其他好文 时间:
2014-07-08 14:18:39
阅读次数:
159
Description
Consider an infinite full binary search tree (see the figure below), the numbers in the nodes are 1, 2, 3, .... In a subtree whose root node is X, we can get the minimum number in this ...
分类:
其他好文 时间:
2014-07-06 11:36:14
阅读次数:
284
deb包的构建的命令为:
dpkg-buildpackage
这样会自动完成所有从源代码包构建二进制包的工作,包括以下几个步骤:
0、清理源代码树(debian/rules clean)
1、构建源代码包(dpkg-source -b)
2、构建程序(debian/rules build)
3、构建二进制包(fakeroot debian/rules binary)...
分类:
其他好文 时间:
2014-07-06 10:38:33
阅读次数:
1940
本题使用所谓的辗转相除法。
还需要逆过来遍历二叉树。可以想象给出的数据点是根节点,然后遍历到根节点(1,1)。
考的是根据给出的规则,总结规律的能力。
#include
namespace BinaryTree2499_1
{
int main()
{
int T, a, b, le, ri;
scanf("%d", &T);
for (int t = 1; t <= T; t...
分类:
其他好文 时间:
2014-07-06 08:11:00
阅读次数:
164