Re: Implementing search algorithm for binary tree

2011-02-23 Thread Alex Osborne
HB writes: > I'm trying to implement searching algorithm for binary tree. > > (defrecord Node [data left-child right-child]) > > (defrecord Tree [root]) > > (defn find-node [tree data] > "Search for a node" > (let [root (:root tree)] > (loop [current root] > (if (= data (:data curre

Re: Implementing search algorithm for binary tree

2011-02-22 Thread Ken Wesson
On Tue, Feb 22, 2011 at 8:37 PM, HB wrote: > Hi, > > I'm trying to implement searching algorithm for binary tree. > Here is my Java implementation: > >    public Node findNode(Integer data) { >        Node current = root; >        while (!data.equals(current.getData())) { >            if (data < c

Implementing search algorithm for binary tree

2011-02-22 Thread HB
Hi, I'm trying to implement searching algorithm for binary tree. Here is my Java implementation: public Node findNode(Integer data) { Node current = root; while (!data.equals(current.getData())) { if (data < current.getData()) current = current.getL