码迷,mamicode.com
首页 >  
搜索关键字:bst    ( 4557个结果
Unique Binary Search Trees II -- leetcode
iven 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 ...
分类:其他好文   时间:2015-05-02 16:35:48    阅读次数:138
Unique Binary Search Trees——LeetCode
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.....
分类:其他好文   时间:2015-05-01 14:40:44    阅读次数:125
BZOJ 1208: [HNOI2004]宠物收养所(BST)
本来想先用set写一遍,再自己写个splay或treap,不过用set过了之后就懒得去写了....以后有空再来写吧..(不会有空的吧= =---------------------------------------------------------------------------------...
分类:其他好文   时间:2015-05-01 11:53:24    阅读次数:178
poj 2418 bst统计字符串
数据比较随机,直接bst可以过。 1 #include 2 #include 3 using namespace std; 4 5 const int N = 101; 6 int tot; 7 8 struct Node 9 {10 Node * ch[2];11 cha...
分类:其他好文   时间:2015-04-29 19:00:55    阅读次数:118
hdu 3791 二叉排序树
中序和一个别的序可以确定一颗bst,而先序和后序不能! 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 11; 7 char str[N]; 8 int cnt; 9 int...
分类:编程语言   时间:2015-04-29 16:59:56    阅读次数:137
hdu 3999 二叉排序树
思考了一会,yy出了一个结论:很显然,对于任意一颗子树中的所有节点来说,根节点必须是第一个插入的,根节点插入以后,这颗子树的其他所有节点会分成两拨,大于根节点权值的和小于根节点权值的,这两部分不会互相影响,可以转化成新的两个更小的子树的构造过程。而在构造过程中要想不破坏原来的bst的结构,就必须满足...
分类:编程语言   时间:2015-04-29 16:56:48    阅读次数:170
生成所有的BST
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 ...
分类:其他好文   时间:2015-04-29 13:32:36    阅读次数:126
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...
分类:其他好文   时间:2015-04-25 21:15:52    阅读次数:186
Recover Binary Search Tree
https://leetcode.com/problems/recover-binary-search-tree/Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without ch...
分类:其他好文   时间:2015-04-25 18:07:43    阅读次数:136
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...
分类:其他好文   时间:2015-04-25 15:11:01    阅读次数:135
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!