码迷,mamicode.com
首页 >  
搜索关键字:bst    ( 4557个结果
[LeetCode] 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.方法:为了使BST高度平衡,要找链表中的中值作为当前根节点。/** * Defin...
分类:其他好文   时间:2014-08-04 20:37:47    阅读次数:194
Validate Binary Search Tree leetcode java
题目: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 on....
分类:编程语言   时间:2014-08-04 13:57:17    阅读次数:242
LeetCode——Unique Binary Search Trees
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 \ ...
分类:其他好文   时间:2014-08-02 15:34:34    阅读次数:221
平衡二叉树(解惑)
平衡二叉树定义(AVL):它或者是一颗空树,或者具有以下性质的二叉树:它的左子树和右子树的深度之差的绝对值不超过1,且它的左子树和右子树都是一颗平衡二叉树。 平衡因子(bf):结点的左子树的深度减去右子树的深度,那么显然-1 很显然,平衡二叉树是在二叉排序树(BST)上引入的,就是为了解决二叉排序树的不平衡性导致时间复杂度大大下降,那么AVL就保持住了(BST)的最好时间复杂度O(lo...
分类:其他好文   时间:2014-08-01 19:49:22    阅读次数:296
Convert Sorted List to Binary Search Tree leetcode java
题目:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.题解:之前做过一道是从sorted array转换到BinarySearc....
分类:编程语言   时间:2014-08-01 04:54:21    阅读次数:310
Unique Binary Search Trees II leetcode java
题目: 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....
分类:编程语言   时间:2014-08-01 04:53:31    阅读次数:279
Unique Binary Search Trees leetcode java
题目: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 B....
分类:编程语言   时间:2014-08-01 04:53:11    阅读次数:272
[leetcode]Convert Sorted Array 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-07-31 23:20:00    阅读次数:270
[leetcode]Recover Binary Search Tree
Recover Binary Search TreeTwo elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A sol...
分类:其他好文   时间:2014-07-31 23:13:00    阅读次数:223
[leetcode]Validate Binary Search Tree
Validate Binary Search TreeGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtre...
分类:其他好文   时间:2014-07-31 23:11:40    阅读次数:225
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!