node.py
Node implementation for Red-Black Tree data structure.
This module defines the Node class that represents individual nodes in a Red-Black Tree. Each node contains data and maintains the tree’s structural properties including color, parent-child relationships, and black height for efficient tree balancing operations.
Classes
- Node
Represents a single node in a Red-Black Tree with all necessary attributes for maintaining tree balance and performing tree operations.
- class node.Node(data: object, color: int, parent: Node | None, left: Node | None, right: Node | None)[source]
Bases:
objectImplements a node in a red-black tree
- _data
Value of the node.
- _color
Color of the node. (1: black, 0: red)
- Type:
int
- _black_height
Black height of the node.
- property black_height: int
Returns the black height of the node. :returns: The black height of the node. :rtype: int
- property color: int
Returns the node’s color :returns: Color of the node (1: black, 0: red) :rtype: int
- property data
Returns the node’s value.
- property left
Returns the left child of the node
- property parent
Returns the node’s parent.
- property right
Returns the node’s right child.