A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes w...
分类:
其他好文 时间:
2015-03-09 00:24:54
阅读次数:
207
An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any...
分类:
其他好文 时间:
2015-03-08 21:23:08
阅读次数:
173
1.题目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 unique BST's. 1 3 3 2 1
\ ...
分类:
其他好文 时间:
2015-03-08 20:13:09
阅读次数:
116
标题:Reverse Bits通过率:27.6%难度:简单Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as0000001010010...
分类:
其他好文 时间:
2015-03-08 20:07:28
阅读次数:
120
#include#includeusing namespace std;const int MAX=1010;int n;int arr[MAX]; //存放原始数组int arrI=0;int CBT[MAX]; //二叉排序树层序遍历序列【思维】中序遍历在数组中存放的就是层序...
分类:
其他好文 时间:
2015-03-08 18:40:53
阅读次数:
132
二分查找伪代码:迭代Binary-Search(A,low,high,x)while(low<=high)
mid=(low+high)/2
if(A[mid]==x)
returnmid
elseif(A[mid]>x)
high=mid-1
else
low=mid+1
returnnull
二分查找伪代码:递归Binary-Search(A,low,high,x)
if(low>high)
returnnull
m..
分类:
编程语言 时间:
2015-03-08 17:24:45
阅读次数:
232
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 equals
the given sum.
/**
* Definition for binary tree
* struct Tree...
分类:
其他好文 时间:
2015-03-08 17:12:04
阅读次数:
103
DescriptionYou are to determine the value of the leaf node in a given binary tree that is the terminal node of a path of least value from the root of ...
分类:
其他好文 时间:
2015-03-08 12:59:07
阅读次数:
147
1.题目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: Recursive solution is trivial, co...
分类:
其他好文 时间:
2015-03-08 11:47:11
阅读次数:
136
1.题目Given an array where elements are sorted in ascending order, convert it to a height balanced BST.2.解决方案1 struct Node{
TreeNode* t;
int l;
int r;
Node(vector &num, int l, int r)...
分类:
其他好文 时间:
2015-03-08 10:28:52
阅读次数:
148