码迷,mamicode.com
首页 >  
搜索关键字:bst    ( 4557个结果
Transform a BST to greater sum tree
Given a BST, transform it into greater sum tree where each node contains sum of all nodes greater than that node.自己想的复杂了,其实就是一个反向的inorder。新的值就是前面所有元素的...
分类:其他好文   时间:2014-11-09 15:07:49    阅读次数:186
Leetcode-Recover BST
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-11-09 07:30:45    阅读次数:155
Leetcode-Validate BST
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-11-09 06:19:31    阅读次数:173
Leetcode-Convert Sorted Array to BST
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.Solution: 1 /** 2 * Definition for binary tree 3 * .....
分类:其他好文   时间:2014-11-09 00:58:31    阅读次数:213
Leetcode-Convert Sorted List to BST.
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.Solution: 1 /** 2 * Definition for singl....
分类:其他好文   时间:2014-11-09 00:52:30    阅读次数:316
B树、B-tree B+树、B*树
BST 即二叉搜索树: 1.所有非叶子结点至多拥有两个儿子(Left和Right); 2.所有结点存储一个关键字; 3.非叶子结点的左指针指向小于其关键字的子树,右指针指向大于其关键字的子树; 如: B-树(B树) 是一种多路搜索树(并不是二叉的): 1.定义任意非叶子结点最多只有M个儿子;且M>2; 2.根结点的儿子数为[2, M]; 3.除根结点以外的非叶子结点的儿子数...
分类:其他好文   时间:2014-11-07 22:05:05    阅读次数:310
有效二叉查找树判断(java实现)
leetcode 原题 :(即判断二叉树是否为二叉查找树)Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subt...
分类:编程语言   时间:2014-11-05 22:54:17    阅读次数:204
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. 1 /** 2 * Definition for singly-linked ....
分类:其他好文   时间:2014-11-03 23:53:07    阅读次数:185
C++模板实现的AVL树
1 AVL树的定义 AVL树是一种自平衡二叉排序树,它的特点是任何一个节点的左子树高度和右子树的高度差在-1,0,1三者之间。AVL树的任何一个子树都是AVL树。 2 AVL树的实现 AVL树本质是一种二叉排序树,所以二叉排序树的任何性质AVL树都具有,但是AVL树稍微复杂的地方就是AVL树必须满足平衡条件,具体跟BST不同的地方主要体现在插入,删除操作。 插入操作:当插入之后可能会出现不...
分类:编程语言   时间:2014-11-03 19:25:21    阅读次数:183
【暴力】vijos P1897 学姐吃牛排
判断堆:递归判断每个节点的孩子是否都比其父亲大(小)。判断BST:中序遍历是否有序。 1 #include 2 using namespace std; 3 #define lc (rtb[i-1]) {f2=0; break;}18 if(f2) return 1;19 retur...
分类:其他好文   时间:2014-11-01 08:37:15    阅读次数:290
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!