Module: Comparable
- Defined in:
- lib/tree_handler/node.rb
Instance Method Summary collapse
Instance Method Details
#compare(node_A, node_B) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tree_handler/node.rb', line 12 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 |