lib/binary_search_tree/tree.rb
def search(value, node = root)
      # The node not found
      return if node.nil?

      # Recursion to find the node
      return search(value, node.left) if value < node.value
      return search(value, node.right) if value > node.value

      node
    end
# Searches the BST Tree (or a sub-tree denoted by `node`) for a given value and return its node.
# @param value [Numeric] the value to search
# @param node [BinarySearchTree::Node] the root node of the tree/sub-tree
# @return [BinarySearchTree::Node, nil] the node corresponding to the given value
Searches the BST Tree (or a sub-tree denoted by `node`) for a given value and return its node.
Searches the BST Tree ( or a sub - tree denoted by ` node ` ) for a given value and return its node .
def search(value, node = root)
      return if node.nil?
      return search(value, node.left) if value < node.value
      return search(value, node.right) if value > node.value
      node
    end
def search ( value , node = root ) return if node . nil? return search ( value , node . left ) if value < node . value return search ( value , node . right ) if value > node . value node end
Searches the BST Tree (or a sub-tree denoted by `node`) for a given value and return its node.
Searches the BST Tree ( or a sub - tree denoted by ` node ` ) for a given value and return its node .
# The node not found # Recursion to find the node
the node corresponding to the given value
the node corresponding to the given value
BinarySearchTree::Node, nil
value
the value to search
the value to search
node
the root node of the tree/sub-tree
the root node of the tree / sub - tree
root