Skip to content

Commit 606d93c

Browse files
authored
Update red_black_tree.py
1 parent f808b7e commit 606d93c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

data_structures/binary_tree/red_black_tree.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ def remove(self, label: int) -> RedBlackTree:
268268
elif self.right:
269269
self.right.remove(label)
270270
return self.parent or self
271-
271+
# It's easier to balance a node with at most one child,
272+
# so we replace this node with the greatest one less than
273+
# it and remove that.
272274
def _remove_repair(self) -> None:
273275
"""Repair the coloring after removal."""
274276
if (

0 commit comments

Comments
 (0)