Skip to content

Commit

Permalink
*
Browse files Browse the repository at this point in the history
  • Loading branch information
imteekay committed Feb 28, 2024
1 parent ee83eb1 commit 2fef76d
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class BST {
if (parent === null && this.left === null && this.right === null) return;

if (value === this.value) {
// when the node has children: get the smallest node from the right subtree and replace the removed node with this one
// when the node has children:
// get the smallest node from the right subtree and replace the removed node with this one
if (this.left && this.right) {
let smallestNodeValue = this.right._findSmallestNodeValue();
this.right.remove(smallestNodeValue, this);
Expand Down

0 comments on commit 2fef76d

Please sign in to comment.