码迷,mamicode.com
首页 >  
搜索关键字:bst    ( 4557个结果
Convert Sorted List to Balanced Binary Search Tree (BST)
(http://leetcode.com/2010/11/convert-sorted-list-to-balanced-binary.html)Given a singly linked list where elements are sorted in ascending order, conv...
分类:其他好文   时间:2015-01-18 22:18:49    阅读次数:202
【leetcode】Convert Sorted List to Binary Search Tree (middle)
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.思路:题目看上去好像很难,但实际上很简单,递归做就行,每次找到左右子树对应的子链表...
分类:其他好文   时间:2015-01-18 21:03:17    阅读次数:241
【BST】判断节点r和s是不是一个为祖先,另一个为后代
题目:EPI 书上的代码我认为有错。我的代码如下所示,时间复杂度为O(h),h为二叉树的高度。 //该函数不允许r和s为nullptr,且要求r、m、s三个指针互不相等 bool is_r_s_descendant_and_ancestor(shared_ptr r, shared_ptr m, shared_ptr s) { if (m == nullptr || r == nul...
分类:其他好文   时间:2015-01-18 14:27:37    阅读次数:265
UVALive 5058 Counting BST 数学
B - Counting BST Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit Status Practice UVALive 5058DescriptionBinary Search Tree (BST) ...
分类:其他好文   时间:2015-01-18 11:46:37    阅读次数:161
[LeetCode] 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-01-18 09:17:43    阅读次数:146
[C++]LeetCode: 100 Convert Sorted Array to Binary Search Tree (AVL树)
题目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 思路:给出一个排序的数组,如何构造一个平衡二叉查找树?平衡二叉查找树要求任一结点的左右子树的高度差不能超过一,也叫做高度平衡树。如果让我们从一个排序数组中选取一个元素做树的根,我们会选择哪一个...
分类:编程语言   时间:2015-01-16 16:51:25    阅读次数:237
LeetCode--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. Calling next() will return the next smallest number in the BST. Note: next()...
分类:其他好文   时间:2015-01-16 16:50:57    阅读次数:152
Validate Binary Search Tree Leetcode Python
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 ke...
分类:编程语言   时间:2015-01-16 10:12:49    阅读次数:163
Convert Binary Search Tree (BST) to Sorted Doubly-Linked List
(http://leetcode.com/2010/11/convert-binary-search-tree-bst-to.html)Convert a BST to a sorted circular doubly-linked list in-place. Think of the left ...
分类:其他好文   时间:2015-01-16 08:42:31    阅读次数:156
【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-01-15 23:35:43    阅读次数:164
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!