MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / sibling

Method sibling

data_structures/binary_tree/red_black_tree.py:431–438  ·  view source on GitHub ↗

Get the current node's sibling, or None if it doesn't exist.

(self)

Source from the content-addressed store, hash-verified

429
430 @property
431 def sibling(self) -> RedBlackTree | None:
432 """Get the current node's sibling, or None if it doesn't exist."""
433 if self.parent is None:
434 return None
435 elif self.parent.left is self:
436 return self.parent.right
437 else:
438 return self.parent.left
439
440 def is_left(self) -> bool:
441 """Returns true iff this node is the left child of its parent."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected