<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>handy &#187; Search Algorithms</title>
	<atom:link href="http://sirinsevinc.wordpress.com/category/search-algorithms/feed/" rel="self" type="application/rss+xml" />
	<link>http://sirinsevinc.wordpress.com</link>
	<description>java,webservice,javascript,software algorithms</description>
	<lastBuildDate>Mon, 20 Jul 2009 14:24:24 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='sirinsevinc.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/22dbbb1103eab00233fa34b9029d78b4?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>handy &#187; Search Algorithms</title>
		<link>http://sirinsevinc.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://sirinsevinc.wordpress.com/osd.xml" title="handy" />
		<item>
		<title>InterpolationSearch</title>
		<link>http://sirinsevinc.wordpress.com/2008/02/17/interpolationsearch/</link>
		<comments>http://sirinsevinc.wordpress.com/2008/02/17/interpolationsearch/#comments</comments>
		<pubDate>Sun, 17 Feb 2008 20:31:21 +0000</pubDate>
		<dc:creator>sirin sevinc</dc:creator>
				<category><![CDATA[Search Algorithms]]></category>
		<category><![CDATA[InterpolationSearch]]></category>

		<guid isPermaLink="false">http://sirinsevinc.wordpress.com/?p=16</guid>
		<description><![CDATA[ Interpolation search is an improvement on the binary search algorithm. It differs from binary search in that, instead of choosing the position in the middle of the range being searched, we estimate where the target is likely to fall within that range. In the worst case, interpolation search takes linear time. This worst case [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sirinsevinc.wordpress.com&blog=2562058&post=16&subd=sirinsevinc&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p> Interpolation search is an improvement on the binary search algorithm. It differs from binary search in that, instead of choosing the position in the middle of the range being searched, we estimate where the target is likely to fall within that range. In the worst case, interpolation search takes linear time. This worst case  occurs only if the assumption of uniform distribution is deeply wrong. On average, interpolation search takes time in O(log (log n)), which is extremely small.</p>
<div style="background-color:rgb(245, 245, 245);"><code style="font-size:9pt;"><br />
public class InterpolationSearch {<br />
	public boolean search(double[] data, double target) {<br />
		int bottom = 0;<br />
		int top = data.length - 1;<br />
		while (bottom &lt;= top) {<br />
			double lo = data[bottom];<br />
			double hi = data[top];<br />
			if (lo == hi) {<br />
				return target == lo;<br />
			}<br />
			if ((target  hi)) {<br />
				return false;<br />
			}<br />
			double fraction = (target - lo) / (hi - lo);<br />
			int midpoint = bottom + (int) ((top - bottom) * fraction);<br />
			System.out.println(midpoint);<br />
			if (target &lt; data[midpoint]) {<br />
				top = midpoint - 1;<br />
			} else if (target == data[midpoint]) {<br />
				return true;<br />
			} else {<br />
				bottom = midpoint + 1;<br />
			}<br />
		}<br />
		return false;<br />
	}<br />
	public static void main(String[] args) {<br />
		double[] data=new double[]{4,8,15,16,23,42};<br />
		System.out.println(new InterpolationSearch().search(data, 23));<br />
	}<br />
}<br />
</code></div>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sirinsevinc.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sirinsevinc.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sirinsevinc.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sirinsevinc.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sirinsevinc.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sirinsevinc.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sirinsevinc.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sirinsevinc.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sirinsevinc.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sirinsevinc.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sirinsevinc.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sirinsevinc.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sirinsevinc.wordpress.com&blog=2562058&post=16&subd=sirinsevinc&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://sirinsevinc.wordpress.com/2008/02/17/interpolationsearch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a9d9718257bc3dedcd892134e22b4295?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sirinse</media:title>
		</media:content>
	</item>
		<item>
		<title>BinarySearch</title>
		<link>http://sirinsevinc.wordpress.com/2007/12/03/binarysearch/</link>
		<comments>http://sirinsevinc.wordpress.com/2007/12/03/binarysearch/#comments</comments>
		<pubDate>Mon, 03 Dec 2007 17:09:00 +0000</pubDate>
		<dc:creator>sirin sevinc</dc:creator>
				<category><![CDATA[Search Algorithms]]></category>
		<category><![CDATA[BinarySearch]]></category>

		<guid isPermaLink="false">http://sirinsevinc.wordpress.com/2007/12/03/binarysearch/</guid>
		<description><![CDATA[Binary search is a logarithmic algorithm and executes in O(log2n) time.
Specifically, 1 + log2N iterations are needed to return an answer. In most  cases it is considerably faster than a linear search. It can be implemented  using recursion or iteration, as shown below. In some languages it is more elegantly expressed recursively; however, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sirinsevinc.wordpress.com&blog=2562058&post=7&subd=sirinsevinc&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Binary search is a logarithmic algorithm and executes in O(log<sub>2</sub>n) time.<br />
Specifically, 1 + log<sub>2</sub>N iterations are needed to return an answer. In most  cases it is considerably faster than a linear search. It can be implemented  using recursion or iteration, as shown below. In some languages it is more elegantly expressed recursively; however, in some C-based languages tail  recursion is not eliminated and the recursive version requires more stack space. <a href="http://en.wikipedia.org/wiki/Binary_search_algorithm">http://en.wikipedia.org/wiki/Binary_search_algorithm</a></p>
<p><code>package com.search.binary;<br />
import java.util.Arrays;<br />
import com.sort.quick.QuickSort;<br />
public class BinarySearch {<br />
public int search(int[] data, int target) {<br />
int index = -1;<br />
int bottom = 0;<br />
int top = data.length - 1;<br />
while (bottom &lt;= top) {<br />
int middle = (top + bottom) / 2;<br />
if (target &lt; data[middle]) {<br />
top = middle - 1;<br />
} else if (data[middle] == target) {<br />
return middle;<br />
} else {<br />
bottom = middle + 1;<br />
}<br />
}<br />
return index;<br />
}<br />
public static void main(String[] args) {<br />
int[] data = new int[] { 4, 8, 15, 16, 23, 42 };<br />
System.out.println(new BinarySearch().search(data, 16));<br />
}<br />
}<br />
</code></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sirinsevinc.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sirinsevinc.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sirinsevinc.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sirinsevinc.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sirinsevinc.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sirinsevinc.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sirinsevinc.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sirinsevinc.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sirinsevinc.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sirinsevinc.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sirinsevinc.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sirinsevinc.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sirinsevinc.wordpress.com&blog=2562058&post=7&subd=sirinsevinc&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://sirinsevinc.wordpress.com/2007/12/03/binarysearch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a9d9718257bc3dedcd892134e22b4295?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sirinse</media:title>
		</media:content>
	</item>
	</channel>
</rss>