From 84638b034ea191e81a3b9905fe262bb95f0e6b0f Mon Sep 17 00:00:00 2001 From: mo Date: Sun, 20 Aug 2017 22:18:50 -0600 Subject: consider using min of right tree instead of max from left subtree. --- spec/binary_trees/delete_from_bst_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/binary_trees/delete_from_bst_spec.rb b/spec/binary_trees/delete_from_bst_spec.rb index 038e154..3bc85d0 100644 --- a/spec/binary_trees/delete_from_bst_spec.rb +++ b/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 -- cgit v1.2.3