countsort

所属分类:数据结构
开发工具:Visual C++
文件大小:1KB
下载次数:128
上传日期:2007-06-06 14:50:01
上 传 者snowtiger999
说明:  计数排序是一个非基于比较的线性时间排序算法。它对输入的数据有附加的限制条件: 1、输入的线性表的元素属于有限偏序集S; 2、设输入的线性表的长度为n,|S|=k(表示集合S中元素的总数目为k),则k=O(n)。 在这两个条件下,计数排序的复杂性为O(n)。 计数排序算法的基本思想是对于给定的输入序列中的每一个元素x,确定该序列中值小于x的元素的个数。一旦有了这个信息,就可以将x直接存放到最终的输出序列的正确位置上。例如,如果输入序列中只有17个元素的值小于x的值,则x可以直接存放在输出序列的第18个位置上。 计数排序算法没有用到元素间的比较,它利用元素的实际值来确定它们在输出数组中的位置。因此,计数排序算法不是一个基于比较的排序算法,从而它的计算时间下界不再是Ω(nlogn)。另一方面,计数排序算法之所以能取得线性计算时间的上界是因为对元素的取值范围作了一定限制,即k=O(n)。如果k=n2,n3,..,就得不到线性时间的上界。
(Count ranking is based on a comparison of non-linear time sorting algorithm. Its input data Additional restrictions : 1, the importation of the linear element is a limited poset S; 2. The linear input based on the length of the table n | S | = k (S said set of elements in the total number of k), k = O (n). In these two conditions, the ranking counting for the complexity of O (n). Counting sorting algorithm is the basic idea for a given input sequence of each element x, determine the sequence x value is less than the number of elements. Once this information, it can be placed directly x to the final output the correct sequence position. For example, if the input sequence, only 17 elements in the value of x is less than the value then x can be placed directly on the output sequence of 18 pos)

文件列表:
countsort.cpp (757, 2007-01-29)

计数排序是一个非基于比较的线性时间排序算法。它对输入的数据有附加的限制条件: 1、输入的线性表的元素属于有限偏序集S; 2、设输入的线性表的长度为n,|S|=k(表示集合S中元素的总数目为k),则k=O(n)。 在这两个条件下,计数排序的复杂性为O(n)。 计数排序算法的基本思想是对于给定的输入序列中的每一个元素x,确定该序列中值小于x的元素的个数。一旦有了这个信息,就可以将x直接存放到最终的输出序列的正确位置上。例如,如果输入序列中只有17个元素的值小于x的值,则x可以直接存放在输出序列的第18个位置上。 计数排序算法没有用到元素间的比较,它利用元素的实际值来确定它们在输出数组中的位置。因此,计数排序算法不是一个基于比较的排序算法,从而它的计算时间下界不再是Ω(nlogn)。另一方面,计数排序算法之所以能取得线性计算时间的上界是因为对元素的取值范围作了一定限制,即k=O(n)。如果k=n2,n3,..,就得不到线性时间的上界。

近期下载者

相关文件


收藏者