Skip to content

Commit

Permalink
Make code more lesbar
Browse files Browse the repository at this point in the history
  • Loading branch information
realshouzy committed May 11, 2024
1 parent b802534 commit a86c66d
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions nrw/datastructures/_binary_search_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ def __repr__(self) -> str:
return f"{self.__class__.__name__}(node={self._node!r})"

def __str__(self) -> str:
if self.is_empty:
return ""
return str(self._node)
return str(self._node) if not self.is_empty else ""

@property
def is_empty(self) -> bool:
Expand Down Expand Up @@ -178,11 +176,9 @@ def _ancestor_of_small_right(self) -> BinarySearchTree[ComparableContentT]:
Nachfolger mehr hat. Es ist also später möglich, in einem Baum im
rechten Nachfolger den Vorgänger des linkesten Nachfolgers zu finden.
"""
return (
self
if self._node_of_left_successor._left.is_empty
else self._node._left._ancestor_of_small_right()
)
if self._node_of_left_successor._left.is_empty:
return self
return self._node._left._ancestor_of_small_right()

@property
def _node_of_left_successor(self) -> _BSTNode[ComparableContentT] | None:
Expand Down

0 comments on commit a86c66d

Please sign in to comment.