Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.很简单的二分法,只要给...
分类:
编程语言 时间:
2015-04-14 07:09:13
阅读次数:
133
Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1].No...
分类:
其他好文 时间:
2015-04-14 00:30:05
阅读次数:
163
归并排序的数组实现 1 //折半插入排序 2 void insertSort_Binary(int *arr, int len) 3 { 4 int i, j;//工作指针 5 int low, mid, high;//折半查找指针 6 int current;//暂存待插入...
分类:
编程语言 时间:
2015-04-13 22:37:34
阅读次数:
129
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t...
分类:
其他好文 时间:
2015-04-13 22:34:41
阅读次数:
141
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the next...
分类:
其他好文 时间:
2015-04-13 20:42:55
阅读次数:
102
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.
Below is one possible representation of s1 = "great":
great
/ gr ...
分类:
其他好文 时间:
2015-04-13 19:01:32
阅读次数:
141
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.
For example:
Given the following binary tree,
1...
分类:
其他好文 时间:
2015-04-13 18:57:59
阅读次数:
81
To search a key in a binary search tree, we start from the root and move all the way down, choosing branches according to the comparison results of th...
分类:
其他好文 时间:
2015-04-13 18:33:44
阅读次数:
110
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-04-13 18:25:39
阅读次数:
144
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-04-13 18:14:58
阅读次数:
243