Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
题意:将一个有序数组变成二叉搜索树。
思路:简单的递归。
/**
* Definition for a binary tree node.
* public class TreeNode {...
分类:
其他好文 时间:
2015-05-05 21:59:06
阅读次数:
117
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 and the nodes have the same value.
基本思路:
进行递...
分类:
其他好文 时间:
2015-05-05 19:44:08
阅读次数:
107
https://leetcode.com/problems/balanced-binary-tree/https://leetcode.com/discuss/28162/java-o-n-solution-based-on-maximum-depth-of-binary-treeGiven a b...
分类:
其他好文 时间:
2015-05-05 18:52:21
阅读次数:
128
people 原图 people2 处理后 OpenCV中二值化的方法有多个,其中CV_THRESH_BINARY_INV参数是取反,具体如下 若大于给定的阈值threshhold,为目标点dst(x,y)=0,否则目标点dst(x,y)=max_value,这里设定为250。 threshold_type=CV_THRESH_BINARY_INV:dst(x,y) = 0, if src(x,y)...
分类:
其他好文 时间:
2015-05-05 16:32:23
阅读次数:
157
C++二叉查找树:Binary Search tree
二叉查找树默认左子树的值都比根节点小,右子树都比根节点大,这个定义排除了树中存在值相同节点的可能性。这便是二叉查找树称为一个用关键值KEY快速查找的工具。
二叉树类:
class bst
{
struct Node
{
T data;
Node* L;
...
分类:
编程语言 时间:
2015-05-05 14:28:04
阅读次数:
150
problem:
Given a binary tree, return the postorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [3,2,1].
Note: R...
分类:
其他好文 时间:
2015-05-05 12:45:27
阅读次数:
123
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).
For example:
Given binary tree {3,9,20,#,#,15,7},
...
分类:
其他好文 时间:
2015-05-05 10:40:01
阅读次数:
113
problem:
Given a binary tree, return the preorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,2,3].
Note: Re...
分类:
其他好文 时间:
2015-05-05 10:36:19
阅读次数:
126
题目描述:
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
For example, this binary tree is symmetric:
1
/ 2 2
/ \ / 3 4 4 3
...
分类:
其他好文 时间:
2015-05-05 08:58:49
阅读次数:
146
Binary Search:二分查找实现方式:recursive or iterative注意问题,终止循环条件,移动start,end时边界值,start = mid,end = midTemplate:1. 在排序的数组中找A[i] == i的index,有重复元素存在. (cc150 Ques...
分类:
其他好文 时间:
2015-05-05 08:50:23
阅读次数:
163