<?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>Li Guoliang &#187; 查找</title>
	<atom:link href="http://liguoliang.com/tag/%e6%9f%a5%e6%89%be/feed/" rel="self" type="application/rss+xml" />
	<link>http://liguoliang.com</link>
	<description>ActionScript Flex Java JEE PHP...</description>
	<lastBuildDate>Mon, 21 May 2012 17:04:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>ActionScript实现顺序查找,二分查找</title>
		<link>http://liguoliang.com/2008/actionscript%e5%ae%9e%e7%8e%b0%e9%a1%ba%e5%ba%8f%e6%9f%a5%e6%89%be%e4%ba%8c%e5%88%86%e6%9f%a5%e6%89%be/</link>
		<comments>http://liguoliang.com/2008/actionscript%e5%ae%9e%e7%8e%b0%e9%a1%ba%e5%ba%8f%e6%9f%a5%e6%89%be%e4%ba%8c%e5%88%86%e6%9f%a5%e6%89%be/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 08:48:12 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[查找]]></category>
		<category><![CDATA[算法]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2008/10/261/</guid>
		<description><![CDATA[写的比较潦草,欢迎指正….批评是我前进的动力&#8230;&#8230;
顺序查找实现 Sequential Search

	/**
	 * 顺序查找实现 Sequential Search
	 */
	 public static function sequentialSearch(k:int,<p class='read-more'><a href='http://liguoliang.com/2008/actionscript%e5%ae%9e%e7%8e%b0%e9%a1%ba%e5%ba%8f%e6%9f%a5%e6%89%be%e4%ba%8c%e5%88%86%e6%9f%a5%e6%89%be/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>写的比较潦草,欢迎指正….批评是我前进的动力&#8230;&#8230;</p>
<h3>顺序查找实现 Sequential Search</h3>
<pre class="java" name="code">
	/**
	 * 顺序查找实现 Sequential Search
	 */
	 public static function sequentialSearch(k:int, a:Array):int {
	 	var index:int = -1;
	 	for(var i:int = 0; i<a.length; i++) {
	 		if(a[i] == k) {
	 			index = i;
	 		}
	 	}
	 	return index;
	 }
</pre>
<h3>二分查找实现</h3>
<pre class="java" name="code">
/**
	 * 二分查找实现
	 */
	public static function binarySearch(k:int, a:Array):int {
		var startIndex:int = 0;
		var endIndex:int = a.length - 1;
		var midIndex:int;
		var index:int = -1;

		while(startIndex <= endIndex) {
			midIndex = int((startIndex + endIndex)/2);
			if(k > a[midIndex]) {
				startIndex = midIndex + 1;
			}else {
				endIndex = midIndex - 1;
			}
			if(k == a[midIndex]) {
				index = midIndex;
			}
		}//end of while
		return index;
	}//end of function binarySearch
</pre>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2008/actionscript%e5%ae%9e%e7%8e%b0%e9%a1%ba%e5%ba%8f%e6%9f%a5%e6%89%be%e4%ba%8c%e5%88%86%e6%9f%a5%e6%89%be/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

