diff options
| author | mo <mokha@cisco.com> | 2017-08-20 22:18:50 -0600 |
|---|---|---|
| committer | mo <mokha@cisco.com> | 2017-08-20 22:18:50 -0600 |
| commit | 84638b034ea191e81a3b9905fe262bb95f0e6b0f (patch) | |
| tree | d76107830f030bcc44160327d518c5a9169b2935 /spec | |
| parent | 549116e22321bba074d6b58b9500788266770e38 (diff) | |
consider using min of right tree instead of max from left subtree.
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/binary_trees/delete_from_bst_spec.rb | 9 |
1 files changed, 9 insertions, 0 deletions
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 |
