module TreeHandler::Comparable
Public Instance Methods
compare(node_A, node_B)
click to toggle source
# File lib/tree_handler/comparable.rb, line 3 def compare(node_A, node_B) if node_B.value < node_A.value if node_A.left_child.nil? node_A.left_child = node_B else compare(node_A.left_child, node_B) end else if node_A.right_child.nil? node_A.right_child = node_B else compare(node_A.right_child, node_B) end end end