lib/ruby_algorithms/algorithms/search/graphs/bst.rb
def search( key, node=@root )
    return nil if node.nil?
    if key < node.key
      search( key, node.left )
    elsif key > node.key
      search( key, node.right )
    else
      return node
    end
  end
# Recursive traversal, each time disregarding half of the nodes in the
# tree. Gives O( log n ) time.
Recursive traversal, each time disregarding half of the nodes in the
tree. Gives O( log n ) time.
Recursive traversal each time disregarding half of the nodes in the tree . Gives O ( log n ) time .
def search( key, node=@root )
    return nil if node.nil?
    if key < node.key
      search( key, node.left )
    elsif key > node.key
      search( key, node.right )
    else
      return node
    end
  end
def search ( key , node = @root ) return nil if node . nil? if key < node . key search ( key , node . left ) elsif key > node . key search ( key , node . right ) else return node end end
Recursive traversal, each time disregarding half of the nodes in the
tree.
Recursive traversal each time disregarding half of the nodes in the tree .
key
node