数据结构
hell2pradise
这个作者很懒,什么都没留下…
展开
-
哈希表练习
#include#include#include#includetypedef unsigned __int64 Uint;using namespace std;struct Hash_elem{ //hash_table的元素 Uint hash_key; int hash_value;};struct Hash_table{ Hash_elem *table; in原创 2009-08-13 06:30:00 · 794 阅读 · 0 评论 -
二分查找的进一步分析(TAOCP)
<br />首先,证明二叉树的一些性质<br />E=I+2N,其中E为二叉树的外部路径长度,I为二叉树的内部路径长度,N为二叉树的节点数<br />内部路径长度是指根节点到所有结点的路径长度的和<br />外部路径长度是指将二叉树进行扩充之后,根节点到扩充产生的结点的路径的和原创 2010-07-07 21:53:00 · 708 阅读 · 0 评论 -
转+原:RMQ与LCA(From TopCoder Algorithm Tutorials)
原帖地址:http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=lowestCommonAncestor#Range_Minimum_Query_%28RMQ%29RMQ(Range Minimal Query)问题给定一个数组A[1..N],RMQ(A,i,j)就是A[i..j]的最小值的下标。翻译 2010-08-16 16:01:00 · 8382 阅读 · 3 评论 -
位计数(二进制中1的个数)--读Hacker's Delight
计算一个字中1位的数目有时被称为“种群计数”以一个32位的int为例最朴素的方法:检查最后一位,计数,然后无符号右移。int bit_count(unsigned int i){ int count=0; while(i){ count+=i&0x00000001; i>>=1; } return count;}这样的算法复杂度为O(logi),最坏的时候要做32次循环。O(m)算法,m为二进制中1的个数x-1操作将x的二进制表示中的最右边的1改成0,而该位右原创 2010-09-23 12:08:00 · 2630 阅读 · 0 评论