<?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/"
	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>Comments on: Binary Search Tree</title>
	<atom:link href="http://programmingpraxis.com/2010/03/05/binary-search-tree/feed/" rel="self" type="application/rss+xml" />
	<link>http://programmingpraxis.com/2010/03/05/binary-search-tree/</link>
	<description>A collection of etudes, updated weekly, for the education and enjoyment of the savvy programmer</description>
	<lastBuildDate>Sat, 11 Feb 2012 09:48:16 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: IT Certification News &#187; Blog Archive &#187; Programming Is About Keeping Basic Skills Sharp</title>
		<link>http://programmingpraxis.com/2010/03/05/binary-search-tree/#comment-3621</link>
		<dc:creator><![CDATA[IT Certification News &#187; Blog Archive &#187; Programming Is About Keeping Basic Skills Sharp]]></dc:creator>
		<pubDate>Tue, 20 Sep 2011 17:10:57 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=2058#comment-3621</guid>
		<description><![CDATA[[...] binary search and merge sort are good examples. Slowly, you learn more complicated things like creating and modifying a binary search tree. However, after learning these things, you eventually get a job building applications and you [...]]]></description>
		<content:encoded><![CDATA[<p>[...] binary search and merge sort are good examples. Slowly, you learn more complicated things like creating and modifying a binary search tree. However, after learning these things, you eventually get a job building applications and you [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Programming Is About Keeping Basic Skills Sharp &#124; Regular Geek</title>
		<link>http://programmingpraxis.com/2010/03/05/binary-search-tree/#comment-3600</link>
		<dc:creator><![CDATA[Programming Is About Keeping Basic Skills Sharp &#124; Regular Geek]]></dc:creator>
		<pubDate>Fri, 16 Sep 2011 15:01:48 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=2058#comment-3600</guid>
		<description><![CDATA[[...] binary search and merge sort are good examples. Slowly, you learn more complicated things like creating and modifying a binary search tree. However, after learning these things, you eventually get a job building applications and you [...]]]></description>
		<content:encoded><![CDATA[<p>[...] binary search and merge sort are good examples. Slowly, you learn more complicated things like creating and modifying a binary search tree. However, after learning these things, you eventually get a job building applications and you [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert</title>
		<link>http://programmingpraxis.com/2010/03/05/binary-search-tree/#comment-3489</link>
		<dc:creator><![CDATA[Robert]]></dc:creator>
		<pubDate>Wed, 31 Aug 2011 02:41:42 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=2058#comment-3489</guid>
		<description><![CDATA[#  - A presorted list of numbers to search through.
#    - The item to search for in the list.

proc binSrch {lst x} {
    set len [llength $lst]
    if {$len == 0} {
        return -1
    } else {
        set pivotIndex [expr {$len / 2}]
        set pivotValue [lindex $lst $pivotIndex]
        if {$pivotValue == $x} {
            return $pivotIndex
        } elseif {$pivotValue  -1 ? $recursive + $pivotIndex + 1 : -1}]
        } elseif {$pivotValue &gt; $x} {
            set recursive [binSrch [lrange $lst 0 $pivotIndex-1] $x]
            return [expr {$recursive &gt; -1 ? $recursive : -1}]
        }
    }
}]]></description>
		<content:encoded><![CDATA[<p>#  &#8211; A presorted list of numbers to search through.<br />
#    &#8211; The item to search for in the list.</p>
<p>proc binSrch {lst x} {<br />
    set len [llength $lst]<br />
    if {$len == 0} {<br />
        return -1<br />
    } else {<br />
        set pivotIndex [expr {$len / 2}]<br />
        set pivotValue [lindex $lst $pivotIndex]<br />
        if {$pivotValue == $x} {<br />
            return $pivotIndex<br />
        } elseif {$pivotValue  -1 ? $recursive + $pivotIndex + 1 : -1}]<br />
        } elseif {$pivotValue &gt; $x} {<br />
            set recursive [binSrch [lrange $lst 0 $pivotIndex-1] $x]<br />
            return [expr {$recursive &gt; -1 ? $recursive : -1}]<br />
        }<br />
    }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vikas Tandi</title>
		<link>http://programmingpraxis.com/2010/03/05/binary-search-tree/#comment-2931</link>
		<dc:creator><![CDATA[Vikas Tandi]]></dc:creator>
		<pubDate>Wed, 27 Apr 2011 10:35:22 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=2058#comment-2931</guid>
		<description><![CDATA[My implementation in c
http://codepad.org/jnMTN32g]]></description>
		<content:encoded><![CDATA[<p>My implementation in c<br />
<a href="http://codepad.org/jnMTN32g" rel="nofollow">http://codepad.org/jnMTN32g</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill B</title>
		<link>http://programmingpraxis.com/2010/03/05/binary-search-tree/#comment-1278</link>
		<dc:creator><![CDATA[Bill B]]></dc:creator>
		<pubDate>Sat, 29 May 2010 12:32:53 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=2058#comment-1278</guid>
		<description><![CDATA[I got rid of my Java solution and re-did it in Ruby http://codingjunkie.net/?p=295]]></description>
		<content:encoded><![CDATA[<p>I got rid of my Java solution and re-did it in Ruby <a href="http://codingjunkie.net/?p=295" rel="nofollow">http://codingjunkie.net/?p=295</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill B</title>
		<link>http://programmingpraxis.com/2010/03/05/binary-search-tree/#comment-1256</link>
		<dc:creator><![CDATA[Bill B]]></dc:creator>
		<pubDate>Wed, 12 May 2010 04:01:54 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=2058#comment-1256</guid>
		<description><![CDATA[My solution in Java is here http://codingjunkie.net/?p=268]]></description>
		<content:encoded><![CDATA[<p>My solution in Java is here <a href="http://codingjunkie.net/?p=268" rel="nofollow">http://codingjunkie.net/?p=268</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Remco Niemeijer</title>
		<link>http://programmingpraxis.com/2010/03/05/binary-search-tree/#comment-1059</link>
		<dc:creator><![CDATA[Remco Niemeijer]]></dc:creator>
		<pubDate>Fri, 05 Mar 2010 11:00:15 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=2058#comment-1059</guid>
		<description><![CDATA[My Haskell solution (see http://bonsaicode.wordpress.com/2010/03/05/programming-praxis-binary-search-tree/ for a version with comments):

[sourcecode lang=&quot;css&quot;]
import Control.Monad
import System.Random

data BTree k v = Node k v (BTree k v) (BTree k v) &#124; Empty

find :: (k -&gt; k -&gt; Ordering) -&gt; k -&gt; BTree k v -&gt; Maybe v
find _   _ Empty          = Nothing
find cmp k (Node k&#039; v&#039; l r) = case cmp k k&#039; of EQ -&gt; Just v&#039;
                                               LT -&gt; find cmp k l
                                               GT -&gt; find cmp k r

insert :: (k -&gt; k -&gt; Ordering) -&gt; k -&gt; v -&gt; BTree k v -&gt; BTree k v
insert _   k v Empty            = Node k v Empty Empty
insert cmp k v (Node k&#039; v&#039; l r) = case cmp k k&#039; of
    EQ -&gt; Node k v l r
    LT -&gt; Node k&#039; v&#039; (insert cmp k v l) r
    GT -&gt; Node k&#039; v&#039; l (insert cmp k v r)

delete :: (k -&gt; k -&gt; Ordering) -&gt; k -&gt; BTree k v -&gt; IO (BTree k v)
delete _   _ Empty              = return Empty
delete cmp k t@(Node k&#039; v&#039; l r) = case cmp k k&#039; of
    EQ -&gt; fmap (flip deroot t . (== 0)) $ randomRIO (0,1 :: Int)
    LT -&gt; fmap (flip (Node k&#039; v&#039;) r) $ delete cmp k l
    GT -&gt; fmap (      Node k&#039; v&#039;  l) $ delete cmp k r

deroot :: Bool -&gt; BTree k v -&gt; BTree k v
deroot _    Empty              = Empty
deroot _    (Node _ _ l Empty) = l
deroot _    (Node _ _ Empty r) = r
deroot True (Node k v l (Node rk rv rl rr)) =
    Node rk rv (deroot False $ Node k v l rl) rr
deroot _    (Node k v (Node lk lv ll lr) r) =
    Node lk lv ll (deroot True $ Node k v lr r)

toList :: BTree k v -&gt; [(k, v)]
toList Empty          = []
toList (Node k v l r) = toList l ++ (k, v) : toList r
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>My Haskell solution (see <a href="http://bonsaicode.wordpress.com/2010/03/05/programming-praxis-binary-search-tree/" rel="nofollow">http://bonsaicode.wordpress.com/2010/03/05/programming-praxis-binary-search-tree/</a> for a version with comments):</p>
<pre class="brush: css;">
import Control.Monad
import System.Random

data BTree k v = Node k v (BTree k v) (BTree k v) | Empty

find :: (k -&gt; k -&gt; Ordering) -&gt; k -&gt; BTree k v -&gt; Maybe v
find _   _ Empty          = Nothing
find cmp k (Node k' v' l r) = case cmp k k' of EQ -&gt; Just v'
                                               LT -&gt; find cmp k l
                                               GT -&gt; find cmp k r

insert :: (k -&gt; k -&gt; Ordering) -&gt; k -&gt; v -&gt; BTree k v -&gt; BTree k v
insert _   k v Empty            = Node k v Empty Empty
insert cmp k v (Node k' v' l r) = case cmp k k' of
    EQ -&gt; Node k v l r
    LT -&gt; Node k' v' (insert cmp k v l) r
    GT -&gt; Node k' v' l (insert cmp k v r)

delete :: (k -&gt; k -&gt; Ordering) -&gt; k -&gt; BTree k v -&gt; IO (BTree k v)
delete _   _ Empty              = return Empty
delete cmp k t@(Node k' v' l r) = case cmp k k' of
    EQ -&gt; fmap (flip deroot t . (== 0)) $ randomRIO (0,1 :: Int)
    LT -&gt; fmap (flip (Node k' v') r) $ delete cmp k l
    GT -&gt; fmap (      Node k' v'  l) $ delete cmp k r

deroot :: Bool -&gt; BTree k v -&gt; BTree k v
deroot _    Empty              = Empty
deroot _    (Node _ _ l Empty) = l
deroot _    (Node _ _ Empty r) = r
deroot True (Node k v l (Node rk rv rl rr)) =
    Node rk rv (deroot False $ Node k v l rl) rr
deroot _    (Node k v (Node lk lv ll lr) r) =
    Node lk lv ll (deroot True $ Node k v lr r)

toList :: BTree k v -&gt; [(k, v)]
toList Empty          = []
toList (Node k v l r) = toList l ++ (k, v) : toList r
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Programming Praxis &#8211; Binary Search Tree &#171; Bonsai Code</title>
		<link>http://programmingpraxis.com/2010/03/05/binary-search-tree/#comment-1058</link>
		<dc:creator><![CDATA[Programming Praxis &#8211; Binary Search Tree &#171; Bonsai Code]]></dc:creator>
		<pubDate>Fri, 05 Mar 2010 11:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=2058#comment-1058</guid>
		<description><![CDATA[[...] Praxis &#8211; Binary Search&#160;Tree By Remco Niemeijer  In today&#8217;s Programming Praxis exercise we have to implement a Binary Search Tree. Let&#8217;s get started, [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Praxis &#8211; Binary Search&nbsp;Tree By Remco Niemeijer  In today&#8217;s Programming Praxis exercise we have to implement a Binary Search Tree. Let&#8217;s get started, [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

