A node in a B-tree containing keys and child pointers. Examples: >>> node = Node() >>> node.keys []
| 16 | |
| 17 | |
| 18 | class Node: |
| 19 | """A node in a B-tree containing keys and child pointers. |
| 20 | |
| 21 | Examples: |
| 22 | >>> node = Node() |
| 23 | >>> node.keys |
| 24 | [] |
| 25 | """ |
| 26 | |
| 27 | def __init__(self) -> None: |
| 28 | self.keys: list = [] |
| 29 | self.children: list[Node] = [] |
| 30 | |
| 31 | def __repr__(self) -> str: |
| 32 | """Return a string representation of the node. |
| 33 | |
| 34 | Returns: |
| 35 | A string showing the node's keys. |
| 36 | """ |
| 37 | return f"<id_node: {self.keys}>" |
| 38 | |
| 39 | @property |
| 40 | def is_leaf(self) -> bool: |
| 41 | """Check whether this node is a leaf. |
| 42 | |
| 43 | Returns: |
| 44 | True if the node has no children, False otherwise. |
| 45 | """ |
| 46 | return len(self.children) == 0 |
| 47 | |
| 48 | |
| 49 | class BTree: |
no outgoing calls
no test coverage detected