码迷,mamicode.com
首页 >  
搜索关键字:bst    ( 4557个结果
[LeetCode]Binary Search Tree Iterator,解题报告
题目     LeetCode题目如下: mplement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the next smallest number in the...
分类:其他好文   时间:2015-02-09 21:44:38    阅读次数:206
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 ...
分类:其他好文   时间:2015-02-09 14:04:10    阅读次数:148
leetcode[96]Unique Binary Search Trees
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-02-09 14:02:41    阅读次数:123
leetcode[98]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...
分类:其他好文   时间:2015-02-09 14:01:23    阅读次数:110
leetcode[173]Binary Search Tree Iterator
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the next...
分类:其他好文   时间:2015-02-09 00:45:05    阅读次数:159
求一棵二叉树的高度
利用递归来求一棵树的高度,基本思想是:对于每一个非空节点,先求取其左子树的高度,然后求取其右子树的高度,最后取两子树中较高的一个加1作为以该节点为根的树的高度;对于空节点,直接返回0就可以了。求整棵树的高度只需将此思想运用到根节点上即可。struct BST_Node { int m_value; BST_Node* left_child; BST_Node* rigth_c...
分类:其他好文   时间:2015-02-07 09:07:54    阅读次数:260
Unique Binary Search Tree II
这道题和上一道的思路一样,只是在BST的处理上注意下,包括二叉树的复制,二叉树的调整。 1 vector b; 2 class Solution { 3 public: 4 TreeNode* CopyTree(TreeNode* t) 5 { 6 TreeNode*...
分类:其他好文   时间:2015-02-07 00:22:44    阅读次数:246
[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...
分类:其他好文   时间:2015-02-06 14:38:31    阅读次数:133
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 ...
分类:其他好文   时间:2015-02-04 18:03:07    阅读次数:163
二叉排序树的完整实现
在排序中,之前利用大小根堆的方式,保持最小值或者最大值在堆顶端 二叉排序树是保持这棵树一直是有序的 二叉排序树的建立,不同于堆操作只需要对非叶子节点进行处理,保持其大于左右孩子,或者是小于左右孩子,而是需要对每一个点都进行处理,因为他是相对而言更加 严谨的操作 查找一个数据:对于大根堆操作,如果当前值小于根节点,那么这个值在左右分支出现都是由可能得,但是对于BST,如果小那么肯定在...
分类:编程语言   时间:2015-02-03 19:27:04    阅读次数:230
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!