摘要: In computer science, a hash table is an associative array data structure that associates keys with values. The primary operation it supports efficiently is a lookup, where it is given a key, an identifier for the information to be found such as a person's name, and asked to find the correspondin 阅读全文
posted @ 2011-02-21 20:06 SunnyDay2015 阅读(2165) 评论(0) 推荐(0) 编辑
摘要: 选最大或最小值的时候可以用第一节的算法,如果既要最大值,又要最小值,那就先从输入序列中去前两个元素比较大小,将较小者与当前min比较,较大者与当前max比较,需要3次比较。 阅读全文
posted @ 2011-02-21 14:33 SunnyDay2015 阅读(231) 评论(0) 推荐(0) 编辑
摘要: BUCKET-SORT(A)1 n ← length[A]2 for i ← 1 to n3 do insert A[i] into list B[⌊n A[i]⌋]4 for i ← 0 to n - 15 do sort list B[i] with insertion sort6 concatenate the lists B[0], B[1], . . ., B[n - 1] together in order 阅读全文
posted @ 2011-02-21 14:25 SunnyDay2015 阅读(279) 评论(0) 推荐(0) 编辑
摘要: 基数排序是对位数相同的一组数据进行排序的算法。主要依赖一种稳定的排序(比如计数排序)从低到高对每一个数位排序,算法复杂度为sita(d(n+k)),d是数据的位数,(n+k)是计数排序的复杂度。 阅读全文
posted @ 2011-02-21 14:20 SunnyDay2015 阅读(293) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <cstdlib>#include <time.h>using namespace std;//待排数据在[0,k]范围内,也可以改变上下界,不过要注意一定让//这个范围的大小大于或等于待排数据的范围,也可以把k+1理解过为//待排数据的种类数。数组下标从1开始,length是数据总量,k是数据//种类void CountingSort(int A[] , int length , int B[] , int k){ int *C = new int[k]; //初始化,将所有统计数据记为0。 for( 阅读全文
posted @ 2011-02-21 14:06 SunnyDay2015 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 这个定理要证明的是一比较为基础的时间复杂度的下界是O(n*lgn)。证明过程是利用n!<=l<=2^h(不是很明白为什么n!<=l,觉得二者相等),再取对数,得到h>=lg(n!)=Ω(nlgn)。 阅读全文
posted @ 2011-02-21 11:52 SunnyDay2015 阅读(336) 评论(2) 推荐(0) 编辑