Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2...
分类:
其他好文 时间:
2015-07-03 06:55:11
阅读次数:
121
Kth Smallest Element in a BSTGiven a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is alw...
分类:
编程语言 时间:
2015-07-03 00:07:34
阅读次数:
188
平衡二叉树(Balanced Binary Tree)又被称为AVL树(有别于AVL算法),且具有以下性质:它是一 棵空树或它的左右两个子树的高度差的绝对值不超过1,并且左右两个子树都是一棵平衡二叉树。构造与调整方法 平衡二叉树的常用算法有红黑树、AVL、Treap等。 最小二叉平衡树的节点的公式如下 F(n)=F(n-1)+F(n-2)+1 这个类似于一个递归的数列,可以参考Fibonacci数列...
分类:
其他好文 时间:
2015-07-02 22:48:29
阅读次数:
487
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note:
You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.Follow up:
What if the BST is mod...
分类:
其他好文 时间:
2015-07-02 22:37:12
阅读次数:
129
Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's tota...
分类:
其他好文 时间:
2015-07-02 22:30:24
阅读次数:
263
题目:Count Complete Tree NodesGiven acompletebinary tree, count the number of nodes.Definition of a complete binary tree fromWikipedia:In a complete bin...
分类:
其他好文 时间:
2015-07-02 22:25:05
阅读次数:
170
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class...
分类:
其他好文 时间:
2015-07-02 19:31:46
阅读次数:
97
称号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....
分类:
其他好文 时间:
2015-07-02 19:21:40
阅读次数:
98
Given a binary search tree, write a function kthSmallest to find the
kth smallest element in it.
Note:
You may assume k is always valid, 1 ≤ k ≤ BST's total elements.
Follow up:
What if the BST...
分类:
其他好文 时间:
2015-07-02 15:50:38
阅读次数:
178
Given a complete binary tree, count the number of nodes.
Definition of a complete binary tree from Wikipedia:
In a complete binary tree every level, except possibly the last, is completely fille...
分类:
其他好文 时间:
2015-07-02 15:47:37
阅读次数:
119