<?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/%e5%a0%86%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/12.html</link>
		<comments>http://www.juliuschen.com/archives/12.html#comments</comments>
		<pubDate>Mon, 21 Dec 2009 10:12:45 +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/12</guid>
		<description><![CDATA[堆排序是对树形选择排序的改进，它首先将整个待排序列构建成一个堆，然后将堆顶元素与最后一个元素交换，由此得到一个有序元素和一个长度减1的堆。由于交换后新的堆顶元素可能不满足堆的定义，因此需要将新的堆重新进行堆化（堆化无需重新建堆，只需做少许调整），在堆化完成之后再次将堆顶元素与堆的最后一个元素交换，由此再得到一个新的有序元素和一个长度减1的堆。然后再重新进行堆化，再交换。。。这样一直下去，直到整个堆只有一个元素为止。这样也就完成了对序列的排序。由这个排序的过程也可以知道，堆排序和简单选择排序不同，不是从前往后慢慢有序，而是从后往前慢慢有序。 堆排序的C/C++代码实现： void heapify(int sort_array[], int k, int m) { &#160; &#160; int&#160;temp = sort_array[k]; &#160; &#160; for&#160;(int j = 2 * k; j &#60;= m; j *= 2) { &#160; &#160; &#160; &#160; if&#160;(j &#60; m &#38;&#38; sort_array[j] &#60; sort_array[j+1]) ++j; &#160; &#160; &#160; &#160; if&#160;(!(temp &#60; sort_array[j])) break; &#160; &#160; &#160; &#160; sort_array[k] [...]]]></description>
		<wfw:commentRss>http://www.juliuschen.com/archives/12.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 -->
