Ruby-BST/main.rb
#Addhelper function: used to traverse the tree using the compare_proc and add the node at the correct location
Addhelper function: used to traverse the tree using the compare_proc and add the node at the correct location
Addhelper function : used to traverse the tree using the compare_proc and add the node at the correct location
def addHelper(current, item)
    if @compare_proc.call(item, current.value) == -1
      if current.left.nil?
        current.left = Node.new(item)
      else
        addHelper(current.left, item)
      end
    else
      if current.right.nil?
        current.right = Node.new(item)
      else
        addHelper(current.right, item)
      end
    end
  end
def addHelper ( current , item ) if @compare_proc . call ( item , current . value ) == - 1 if current . left . nil? current . left = Node . new ( item ) else addHelper ( current . left , item ) end else if current . right . nil? current . right = Node . new ( item ) else addHelper ( current . right , item ) end end end
Addhelper function: used to traverse the tree using the compare_proc and add the node at the correct location
Addhelper function : used to traverse the tree using the compare_proc and add the node at the correct location
current
<not_specific>
item
<not_specific>