Skip to content

Commit 8cccecf

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent c8747af commit 8cccecf

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

data_structures/binary_tree/red_black_tree.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,11 @@ def check_color_properties(self) -> bool:
357357
# Property 1: Root must be black
358358
if self.parent is None and self.color != 0:
359359
return False
360-
360+
361361
# Property 2: No two consecutive red nodes
362362
if not self.check_coloring():
363363
return False
364-
364+
365365
# Property 3: All paths have same black height
366366
return self.black_height() is not None
367367

@@ -392,7 +392,7 @@ def black_height(self) -> int | None:
392392
# Base case: Leaf node (None is always black)
393393
if self is None:
394394
return 1
395-
395+
396396
# Leaf node case (both children are None)
397397
if self.left is None and self.right is None:
398398
# Count: current node (if black) + leaf (black)
@@ -405,7 +405,7 @@ def black_height(self) -> int | None:
405405
# Validate consistency
406406
if left_bh is None or right_bh is None or left_bh != right_bh:
407407
return None # Inconsistent black heights
408-
408+
409409
# Current node's contribution: add 1 if black
410410
return left_bh + (1 - self.color)
411411
def __contains__(self, label: int) -> bool:

0 commit comments

Comments
 (0)