<?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%b8%8c%e5%b0%94%e6%8e%92%e5%ba%8f/feed" rel="self" type="application/rss+xml" />
	<link>http://www.juliuschen.com</link>
	<description></description>
	<lastBuildDate>Mon, 17 Oct 2011 10:30:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>希尔排序</title>
		<link>http://www.juliuschen.com/archives/10.html</link>
		<comments>http://www.juliuschen.com/archives/10.html#comments</comments>
		<pubDate>Tue, 15 Dec 2009 12:37:25 +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/10</guid>
		<description><![CDATA[希尔排序是插入排序的扩展。希尔排序的一个特点是：子序列的构成不是简单的逐段分割，而是将相隔某个增量的记录组成一个子序列。希尔排序的一个关键是：其步长（也就是增量）的取法，通常认为步长序列中的数字互质很重要。 希尔排序的C/C++代码实现： 和直接插入排序相比，这里的shell_insert只做了两处修改： 1. 前后记录位置的增量不再是1，而是h； 2. sort_array[0]已不能再作为监视哨，而只能作为一个暂存单元，因为式子j -= h并不一定能使j值到达0。因此，这里干脆用一个temp来代替sort_array[0]做为暂存单元，而让sort_array[0]也加入排序，这样的做法也更通用。 关于h，上面程序中，步长序列取的是：1 4 13 40 121 364 1093 3280 9841&#8230;（从1开始，通过乘3加1得到下一个步长），这是由Knuth在1969年提出来的，该方法容易实现，而且即使是对中等大小的文件，效率也相对还可以。其时间复杂度最差时是O(n3/2)。 此外，也还存在效率更好的h序列，如：1 8 23 77 281 1073 4193 16577&#8230; 但这种序列通常也较难实现，而且相对于上面所用的，效率提高上很难超过20%。比如使用 1 8 23&#8230; 这组序列时，时间复杂度最差为O(n4/3)。 另外还有一些取法不好的步长序列，如：1 2 4 8 16 32 64 128 256 &#8230; <a href="http://www.juliuschen.com/archives/10.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
		<wfw:commentRss>http://www.juliuschen.com/archives/10.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 -->

