MCPcopy
hub / github.com/keon/algorithms / Node

Class Node

algorithms/data_structures/b_tree.py:18–46  ·  view source on GitHub ↗

A node in a B-tree containing keys and child pointers. Examples: >>> node = Node() >>> node.keys []

Source from the content-addressed store, hash-verified

16
17
18class 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
49class BTree:

Callers 3

__init__Method · 0.70
_split_childMethod · 0.70
insert_keyMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected