二叉排序树(Binary Sort Tree)又称二叉查找树(Binary Search Tree),亦称二叉搜索树。图from baike二叉排序树或者是一棵空树,或者是具有下列性质的二叉树:(1)若左子树不空,则左子树上所有结点的值均小于它的根结点的值;(2)若右子树不空,则右子树上所有结点的值...
分类:
编程语言 时间:
2015-08-16 13:33:59
阅读次数:
150
The basic idea is to start fromrootand add it to the currentpath, then we recursively visit itsleftandrightsubtrees if they exist; otherwise, we have ...
分类:
其他好文 时间:
2015-08-16 11:58:51
阅读次数:
248
The idea is to add the two binary numbers (represented as strings) from back to forth bit by bit and store the result in the longer string. After the ...
分类:
其他好文 时间:
2015-08-16 01:59:31
阅读次数:
122
这道题考察两个二进制数相加,考虑到输入的是两组string,同时注意在运算时从左到右分别是从低位到高位,因此需要考虑对输入进行翻转处理。...
分类:
其他好文 时间:
2015-08-15 23:09:51
阅读次数:
139
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 le...
分类:
其他好文 时间:
2015-08-15 22:42:42
阅读次数:
138
php浮点数精确运算bc是Binary Calculator的缩写。bc*函数的参数都是操作数加上一个可选的 [int scale],比如string bcadd(string $left_operand, string $right_operand[, int $scale]),如果scale没有...
分类:
Web程序 时间:
2015-08-15 21:27:02
阅读次数:
144
Given a binary tree
struct TreeLinkNode {
TreeLinkNode *left;
TreeLinkNode *right;
TreeLinkNode *next;
}
Populate each next pointer to point to its next right node....
分类:
其他好文 时间:
2015-08-15 20:10:22
阅读次数:
119
This problem is just similar toMinimum Depth of Binary Tree.The first solution also uses recursion (not sure whether it can be called DFS).1 class Sol...
分类:
其他好文 时间:
2015-08-15 19:52:05
阅读次数:
123
对于Convert Sorted array to Binary Search Tree相对简单,使用二分的方式就可以确定左树和右树的范围。一、对于此问题,使用二分的方式也是可以的,但是没有数组的随机访问的特性,需要遍历数组找到list的中间node。为了便于查找中间node可以首先统计节点的个数。...
分类:
其他好文 时间:
2015-08-15 19:51:51
阅读次数:
90
Well, this problem has the highest acceptance rate among all OJ problems. It has a very easy 1-line reursive solution. I am not sure whether this one ...
分类:
其他好文 时间:
2015-08-15 19:49:12
阅读次数:
131