码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
1099. Build A Binary Search Tree (30)
题目要求: A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes with keys less than the node's key....
分类:其他好文   时间:2015-03-31 14:46:43    阅读次数:168
Treap
Treap         Treap是一种动态平衡的BST(Binary Search Tree),它每个节点拥有键值和优先级两种属性。对于键值而言,它是一颗排序二叉树。对于优先级而言,这棵树是堆(优先级最高的是根节点)。可以证明Treap中插入,删除和查找的期望时间复杂度均为O(logn)。关于Treap的更多介绍,可见刘汝佳《训练指南》P230。 一般我们用Treap就是用来替代平衡二叉...
分类:其他好文   时间:2015-03-31 14:40:38    阅读次数:226
leetcode || 50、Pow(x, n)
problem: Implement pow(x, n). Hide Tags  Math Binary Search 题意:求x的n次幂 thinking: (1)最简单想到的是直观上的数学幂函数求法,测试通过。算法时间复杂度为O(n) (2)按照标签提示,使用二分搜索法。pow(x,n) = po...
分类:其他好文   时间:2015-03-31 10:58:50    阅读次数:130
Add Binary
Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". #include #include #include using namespace std; string addBinary(string a, s...
分类:其他好文   时间:2015-03-31 10:56:04    阅读次数:105
03-树2. Tree Traversals Again (25)
03-树2. Tree Traversals Again (25)时间限制200 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, YueAn inorder binary tree traversal can be implemented in a non...
分类:其他好文   时间:2015-03-31 10:28:08    阅读次数:170
NYOJ题目5---Binary String Matching
Binary String Matching 时间限制:3000 ms  |  内存限制:65535 KB 难度:3 描述Given two strings A and B, whose alphabet consist only ‘0’ and ‘1’. Your task is only to tell how many times does A appear as...
分类:其他好文   时间:2015-03-31 09:12:58    阅读次数:122
Java集合中二分查找算法实现
Java集合中二分查找算法实现 Arrays.binarySearch实现了对有序数组特定区间的二分查找,虽然我们觉得很简答,但是阅读源码的确能看到实现这些库的优秀技巧,总是在追求完美和高效。 值得学习的地方有: (1)边界检查; (2)求中位数的时候使用位移操作,而不是 x/2; (3)如果查找的元素不在数组中,通过返回值昭示了应该插入的位置,而不是直接返回-1;...
分类:编程语言   时间:2015-03-30 18:50:14    阅读次数:165
LeetCode 191 Number of 1 Bits
题目描述: Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 32-bit integer ’11' has binary representa...
分类:其他好文   时间:2015-03-30 18:42:17    阅读次数:128
Balanced Binary Tree(LeetCode)
题目:Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1....
分类:其他好文   时间:2015-03-30 16:24:02    阅读次数:129
Path Sum(LeetCode)
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum....
分类:其他好文   时间:2015-03-30 13:24:31    阅读次数:112
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!