Commit 84638b0

mo <mokha@cisco.com>
2017-08-21 04:18:50
consider using min of right tree instead of max from left subtree.
1 parent 549116e
Changed files (1)
spec
spec/binary_trees/delete_from_bst_spec.rb
@@ -193,8 +193,17 @@ they want you to take the largest node's left subtree and make it the child of t
       else
         max = tree.left
         max = max.right while max.right
+        min = tree.right
+        min = min.left while min.left
+
+        puts [max&.value, min&.value].inspect
+
         tree.value = max.value
         tree.left = remove(tree.left, tree.value)
+
+        #tree.value = min.value
+        #tree.right = remove(tree.right, tree.value)
+
       end
     end
     tree