码迷,mamicode.com
首页 >  
搜索关键字:bst    ( 4557个结果
LeetCode - Convert Sorted Array to Binary Search Tree
题目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.思路:总是取中间点为rootpackage bst;public class ConvertSort...
分类:其他好文   时间:2016-01-10 12:55:55    阅读次数:105
[LeetCode] 230. Kth Smallest Element in a BST 解题思路
问题:找出二叉搜索树种第 k 小的元素。 一个深度遍历的应用。使用递归、或者借助栈都可以实现深度遍历。本文代码使用递归实现。
分类:其他好文   时间:2016-01-10 11:35:01    阅读次数:154
LeetCode - Recover Binary Search Tree
题目:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space ...
分类:其他好文   时间:2016-01-09 20:12:12    阅读次数:146
LeetCode - Unique Binary Search Trees II
题目:Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example,Given n = 3, your program should return ...
分类:其他好文   时间:2016-01-09 16:53:50    阅读次数:157
Unique Binary Search Trees
Given n, how many structurally unique BSTs (binary search trees) that store values 1...n?ExampleGiven n = 3, there are a total of 5 unique BST's.1 ...
分类:其他好文   时间:2016-01-08 07:03:30    阅读次数:167
109.Convert Sorted List to Binary Search Tree
问题: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.思路:先遍历一遍链表,将值存入一个vector中,再讲vector中有序....
分类:其他好文   时间:2016-01-06 17:37:56    阅读次数:115
[?]*Closest Binary Search Tree Value II
Given a non-empty binary search tree and a target value, findkvalues in the BST that are closest to the target.Note:Given target value is a floating p...
分类:其他好文   时间:2016-01-06 06:49:06    阅读次数:198
*Closest Binary Search Tree Value
Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target.public class Solution { public int...
分类:其他好文   时间:2016-01-06 06:48:38    阅读次数:147
*Inorder Successor in BST
Given a binary search tree and a node in it, find the in-order successor of that node in the BST.Note: If the given node has no in-order successor in ...
分类:其他好文   时间:2016-01-06 06:45:16    阅读次数:161
LeetCode :: Convert Sorted Array (link list) to Binary Search Tree [tree]
1.Given an array where elements are sorted in ascending order, convert it to a height balanced BST.2.Given a singly linked list where elements are sor...
分类:其他好文   时间:2016-01-03 20:58:24    阅读次数:106
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!