码迷,mamicode.com
首页 >  
搜索关键字:bst    ( 4557个结果
二叉排序树(BST)
二叉排序树(BST) 二叉排序树是空树或者是满足如下性质的树 (1)若它的左子树不空,则左子树上所有关键字的值均小于关键字的值 (2)若它的右子树不空,则右子树上所有关键字的值均大于跟关键字的值。 (3)左右子树各是一颗二叉排序树。说明: 在二叉排序树中插入关键字均为在新建的叶子上,由于找的的插入位...
分类:编程语言   时间:2014-10-12 17:03:28    阅读次数:177
Leetcode:convert_sorted_array_to_binary_search_tree
BST的中序遍历是一个sorted-array,再构造回去成一个BST,先将中间的元素作为根节点,这个节点的左右分别是左子树和右子树。如此递归地进行即可。...
分类:其他好文   时间:2014-10-10 02:19:43    阅读次数:173
Unique Binary Search Trees 三种解法 python
Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1.....
分类:编程语言   时间:2014-10-09 14:37:53    阅读次数:215
Unique Binary Search Trees
[leetcode]Given n, how many structurally unique BST's (binary search trees) that store values 1...n?...
分类:其他好文   时间:2014-10-08 12:00:15    阅读次数:159
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 all 5 unique BST's shown below. 1 3 ...
分类:其他好文   时间:2014-10-08 11:52:35    阅读次数:202
Convert Sorted Array to Binary Search Tree
[leetcode]Given an array where elements are sorted in ascending order, convert it to a height balanced BST....
分类:其他好文   时间:2014-10-08 10:09:55    阅读次数:164
leetcode - 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 nodes with keys less than the node's key.Th...
分类:其他好文   时间:2014-10-06 19:32:50    阅读次数:173
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 is pretty straight forward. Could you devis...
分类:其他好文   时间:2014-10-06 18:43:20    阅读次数:201
Leetcode:unique_binary_search_trees
给定数n,问有多少种不同的BST(二叉搜索树)...
分类:其他好文   时间:2014-10-06 01:31:09    阅读次数:341
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. /** * Definition for singly-linked list. * struct ListNode { * int val; * Lis...
分类:其他好文   时间:2014-10-03 17:21:45    阅读次数:167
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!