<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>一花一世界 &#187; 计数排序</title>
	<atom:link href="http://www.juliuschen.com/archives/tag/%e8%ae%a1%e6%95%b0%e6%8e%92%e5%ba%8f/feed" rel="self" type="application/rss+xml" />
	<link>http://www.juliuschen.com</link>
	<description>谈笑间，樯橹灰飞烟灭</description>
	<lastBuildDate>Sun, 29 Aug 2010 10:32:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>计数排序</title>
		<link>http://www.juliuschen.com/archives/14.html</link>
		<comments>http://www.juliuschen.com/archives/14.html#comments</comments>
		<pubDate>Thu, 24 Dec 2009 10:34:17 +0000</pubDate>
		<dc:creator>Julius Chen</dc:creator>
				<category><![CDATA[Sorting]]></category>
		<category><![CDATA[排序算法]]></category>
		<category><![CDATA[计数排序]]></category>
		<category><![CDATA[非比较排序]]></category>

		<guid isPermaLink="false">http://www.juliuschen.com/archives/14</guid>
		<description><![CDATA[计数排序(Counting Sort)是一种非基于比较的排序方法，它要求所有的待排元素都必须是≥0的整数。它的排序步骤是首先根据数组中最大的元素值加1作为长度来定义一个计数数组C。然后统计待排数组中每个值为i的元素出现的次数，存入C的第i项中。再对所有的计数累加（从C中的第一项开始，每一项和前一项相加）。最后再反向填充辅助数组：将每个元素i放在辅助数组的第C(i)项，每放一个元素就将C(i)减去1。这样完成之后排序就已完毕，有序序列已存储在辅助数组中。如果结果想用原数组输出，则将它们从辅助数组考回到原数组即可。 计数排序的C/C++代码实现： void counting_sort(int a[], int length) { &#160; &#160; int&#160;i; &#160; &#160; int&#160;c[MAX_VALUE] = {0}; &#160; &#160; int&#160;temp[ARRAY_SIZE] = {0}; &#160; &#160; for&#160;(i = 0; i &#60; length; ++i) c[a[i]]++; &#160; &#160; for&#160;(i = 1; i &#60; MAX_VALUE; ++i) c[i] += c[i-1]; &#160; &#160; for&#160;(i = length - 1; i &#62;= 0; --i) [...]]]></description>
		<wfw:commentRss>http://www.juliuschen.com/archives/14.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
<noscript><a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></a></noscript>
<!-- End Of Analytics Code -->
