java-algorithms-implementation
java-algorithms-implementation copied to clipboard
tip about method BinarySearchTree.replaceNodeWithNode()
https://github.com/phishman3579/java-algorithms-implementation/blob/356dfb1daff89b983194c192c7534fa3b3a30126/src/com/jwetherell/algorithms/data_structures/BinarySearchTree.java#L375
this code is not wrong. I wonder can you modify it.
in my opinion, replacementNode must be a leaf node.
so if it is a left leaf node or a right leaf node,
just make sure replacementParent.lesser = null;
or replacementParent.greater= null;