码迷,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./** * Definition for binary tree * public class TreeN...
分类:其他好文   时间:2014-08-30 01:10:48    阅读次数:333
LeetCode 99 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 is pretty straight forward. Could you devis...
分类:其他好文   时间:2014-08-29 21:28:08    阅读次数:313
LeetCode: Validata Binary Search Tree
LeetCode: Validata Binary Search TreeGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The l...
分类:其他好文   时间:2014-08-28 23:59:16    阅读次数:421
LeetCode: Recover Binary Search Tree
LeetCode: Recover Binary Search TreeTwo elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure....
分类:其他好文   时间:2014-08-28 23:58:36    阅读次数:385
Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only n...
分类:其他好文   时间:2014-08-28 20:57:46    阅读次数:201
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 is ...
分类:其他好文   时间:2014-08-28 19:33:55    阅读次数:266
【算法导论学习-24】二叉树专题2:二叉搜索树(Binary Search Tree,BST)
二叉搜索树(Binary Search Tree,BST)的一点总结。...
分类:其他好文   时间:2014-08-28 14:52:59    阅读次数:215
[LeetCode系列]有序链表转换为平衡BST的递归解法
给定有序链表(元素由小到大), 试问如何将其转换为一个平衡BST?平衡BST: 任意节点的左右子树的深度差值不大于1.主要思想是用递归. Trick是使用快慢指针来获取中间节点. 获得中间节点后, 将其设为此次递归的root, 随后删除此节点, 并将前一节点的next置NULL. 随后, 对中间节点...
分类:其他好文   时间:2014-08-28 11:15:19    阅读次数:162
Convert Sorted Array to Binary Search Tree & Convert Sorted List to Binary Search Tree
Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.方法:将有序数组转为平...
分类:其他好文   时间:2014-08-27 23:17:18    阅读次数:278
UVA 10821 - Constructing BST(贪心构造)
UVA 10821 - Constructing BST 题目链接 题意:有1 - n的数字,要构造一棵高度不超过h的BST,并且要字典序最小的,输出序列 思路:贪心构造,既然字典序最小,那么每个子树的根都要尽量小,那么也就是右子树尽量填满,按照这个策略去dfs构造即可 代码: #include #include #include using namespace...
分类:其他好文   时间:2014-08-25 14:59:04    阅读次数:196
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!