<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	
	>
<channel>
	<title>《内部排序算法：冒泡排序》的评论</title>
	<atom:link href="http://shiyanjun.cn/archives/795.html/feed" rel="self" type="application/rss+xml" />
	<link>http://shiyanjun.cn/archives/795.html</link>
	<description>简单之美，难得简单，享受简单的唯美。</description>
	<lastBuildDate>Wed, 19 Feb 2025 08:08:30 +0000</lastBuildDate>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.2</generator>
	<item>
		<title>作者：Yanjun</title>
		<link>http://shiyanjun.cn/archives/795.html#comment-60077</link>
		<dc:creator><![CDATA[Yanjun]]></dc:creator>
		<pubDate>Sun, 29 Apr 2018 15:29:13 +0000</pubDate>
		<guid isPermaLink="false">http://shiyanjun.cn/?p=795#comment-60077</guid>
		<description><![CDATA[交换a和b：
    tmp = a;
    a = b;
    b = temp;
上面不是移动了3次，如果交换n-1次，移动总次数3(n-1)。]]></description>
		<content:encoded><![CDATA[<p>交换a和b：<br />
    tmp = a;<br />
    a = b;<br />
    b = temp;<br />
上面不是移动了3次，如果交换n-1次，移动总次数3(n-1)。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：Eason</title>
		<link>http://shiyanjun.cn/archives/795.html#comment-60063</link>
		<dc:creator><![CDATA[Eason]]></dc:creator>
		<pubDate>Fri, 20 Apr 2018 07:18:17 +0000</pubDate>
		<guid isPermaLink="false">http://shiyanjun.cn/?p=795#comment-60063</guid>
		<description><![CDATA[最坏情况：逆序

需要进行n-1趟排序。
有序区数组大小为0时：比较n-1次，交换n-1次，移动3(n-1)次；
有序区数组大小为1时：比较n-2次，交换n-2次，移动3(n-2)次；
……
有序区数组大小为n-3时：比较2次，交换2次，移动3*2次；
有序区数组大小为n-2时：比较1次，交换1次，移动3*1次；
比较次数为：1+2+……+(n-1) = n(n-1)/2
移动次数为：3(1+2+……+(n-1)) = 3n(n-1)/2 

这个地方的移动3(n-1)是怎么计算得来的]]></description>
		<content:encoded><![CDATA[<p>最坏情况：逆序</p>
<p>需要进行n-1趟排序。<br />
有序区数组大小为0时：比较n-1次，交换n-1次，移动3(n-1)次；<br />
有序区数组大小为1时：比较n-2次，交换n-2次，移动3(n-2)次；<br />
……<br />
有序区数组大小为n-3时：比较2次，交换2次，移动3*2次；<br />
有序区数组大小为n-2时：比较1次，交换1次，移动3*1次；<br />
比较次数为：1+2+……+(n-1) = n(n-1)/2<br />
移动次数为：3(1+2+……+(n-1)) = 3n(n-1)/2 </p>
<p>这个地方的移动3(n-1)是怎么计算得来的</p>
]]></content:encoded>
	</item>
</channel>
</rss>
