Skip to content

Commit 71cba73

Browse files
authored
Update red_black_tree.py
1 parent 8cccecf commit 71cba73

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

data_structures/binary_tree/red_black_tree.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,14 @@ def _remove_repair(self) -> None:
335335
self.parent.color = 0
336336
self.parent.sibling.color = 0
337337

338-
def check_color_properties(self) -> bool:
338+
339339
def check_color_properties(self) -> bool:
340340
"""
341341
Verify that all Red-Black Tree properties are satisfied:
342-
1. Root node is black
343-
2. No two consecutive red nodes (red node cannot have red children)
344-
3. All paths from any node to its leaf descendants have the same number of black nodes
342+
# Root node is black
343+
# No two consecutive red nodes (red node cannot have red children)
344+
# All paths from any node to its leaf descendants have
345+
# the same number of black nodes
345346
346347
Returns:
347348
True if all properties are satisfied, False otherwise
@@ -373,7 +374,7 @@ def check_coloring(self) -> bool:
373374
return False
374375
return not (self.right and not self.right.check_coloring())
375376

376-
def black_height(self) -> int | None:
377+
def black_height(self) -> int | None:
377378
"""
378379
Calculate the black height of the tree and verify consistency
379380
- Black height = number of black nodes from current node to any leaf

0 commit comments

Comments
 (0)