<?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>Function13.net &#187; algorithm</title>
	<atom:link href="http://www.function13.net/tag/algorithm/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.function13.net</link>
	<description>A blog about technology and code.</description>
	<lastBuildDate>Tue, 23 Feb 2010 07:37:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Deterministic Linear Time k-Select Algorithm</title>
		<link>http://www.function13.net/2009/12/03/deterministic-linear-time-k-select-algorithm/</link>
		<comments>http://www.function13.net/2009/12/03/deterministic-linear-time-k-select-algorithm/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 11:48:18 +0000</pubDate>
		<dc:creator>lijamez</dc:creator>
				<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[selection]]></category>

		<guid isPermaLink="false">http://www.function13.net/?p=385</guid>
		<description><![CDATA[
This is an implementation of linear time selection by Blum, Floyd, Pratt, Rivest, and Tarjon in Java.
Pseudocode:

BSelect(A,k):
    If &#124;A&#124; == 1 return A[1]
    p = GoodPivot(A)
    S = { A[i] &#124; A[i] &#60; p }
    L = { A[i] &#124; A[i] &#62; p [...]]]></description>
			<content:encoded><![CDATA[<p><span><img class="aligncenter size-full wp-image-396" title="Code" src="http://www.function13.net/wp-content/Code.png" alt="Code" width="339" height="166" /></span></p>
<p><span>This is an implementation of linear time selection by Blum, Floyd, Pratt, Rivest, and Tarjon in Java.</span></p>
<pre><span>Pseudocode:

BSelect(A,k):</span>
<span>    If |A| == 1 return A[1]</span>
<span>    p = GoodPivot(A)</span>
<span>    S = { A[i] | A[i] &lt; p }</span>
<span>    L = { A[i] | A[i] &gt; p }</span>
<span>    If |S| &gt;= k return BSelect(S,k)</span>
<span>    else if |S| == k-1 return p</span>
<span>    else return BSelect(L, k-|S|-1)</span>

<span>GoodPivot(A):</span>
<span>    Divide A into n/5 groups of 5 elements each</span>
<span>    Find the median of each group</span>
<span>    Use BSelect to find the median, p, of the n/5 medians</span>
<span>    Return p</span></pre>
<p><span><a href="http://snipt.net/lijamez/deterministic-linear-time-k-select">View implementation</a></span></p>
<p><span><br />
</span></p>
<p><!-- Begin SexyBookmarks Menu Code --></p>
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-spaced">
<ul class="socials">
<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.function13.net/2009/12/03/deterministic-linear-time-k-select-algorithm/&amp;title=Deterministic+Linear+Time+k-Select+Algorithm" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.function13.net/2009/12/03/deterministic-linear-time-k-select-algorithm/&amp;title=Deterministic+Linear+Time+k-Select+Algorithm" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
<li class="sexy-delicious">
			<a href="http://delicious.com/post?url=http://www.function13.net/2009/12/03/deterministic-linear-time-k-select-algorithm/&amp;title=Deterministic+Linear+Time+k-Select+Algorithm" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.function13.net/2009/12/03/deterministic-linear-time-k-select-algorithm/&amp;title=Deterministic+Linear+Time+k-Select+Algorithm" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.function13.net/2009/12/03/deterministic-linear-time-k-select-algorithm/&amp;t=Deterministic+Linear+Time+k-Select+Algorithm" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.function13.net/2009/12/03/deterministic-linear-time-k-select-algorithm/&amp;title=Deterministic+Linear+Time+k-Select+Algorithm&amp;summary=%0D%0A%0D%0AThis%20is%20an%20implementation%20of%20linear%20time%20selection%20by%20Blum%2C%20Floyd%2C%20Pratt%2C%20Rivest%2C%20and%20Tarjon%20in%20Java.%0D%0APseudocode%3A%0D%0A%0D%0ABSelect%28A%2Ck%29%3A%0D%0A%20%20%20%20If%20%7CA%7C%20%3D%3D%201%20return%20A%5B1%5D%0D%0A%20%20%20%20p%20%3D%20GoodPivot%28A%29%0D%0A%20%20%20%20S%20%3D%20%7B%20A%5Bi%5D%20%7C%20A%5Bi%5D%20%26lt%3B%20p%20%7D%0D%0A%20%20%20%20L%20%3D%20%7B%20A%5Bi%5D%20%7C%20A%5Bi%5D%20%26gt%3B%20p%20%7D%0D%0A%20%20%20%20If%20%7CS%7C%20%26gt%3B%3D%20k%20return%20BSelect%28S%2Ck%29%0D%0A%20%20%20%20else&amp;source=Function13.net" rel="nofollow" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
<li class="sexy-google">
			<a href="" rel="nofollow" title=""></a>
		</li>
<li class="sexy-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://www.function13.net/2009/12/03/deterministic-linear-time-k-select-algorithm/&amp;title=Deterministic+Linear+Time+k-Select+Algorithm" rel="nofollow" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://www.function13.net/2009/12/03/deterministic-linear-time-k-select-algorithm/&amp;n=Deterministic+Linear+Time+k-Select+Algorithm&amp;pli=1" rel="nofollow" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<p><!-- End SexyBookmarks Menu Code --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.function13.net/2009/12/03/deterministic-linear-time-k-select-algorithm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
