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

Class Node

data_structures/binary_tree/basic_binary_tree.py:8–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6
7@dataclass
8class Node:
9 data: int
10 left: Node | None = None
11 right: Node | None = None
12
13 def __iter__(self) -> Iterator[int]:
14 if self.left:
15 yield from self.left
16 yield self.data
17 if self.right:
18 yield from self.right
19
20 def __len__(self) -> int:
21 return sum(1 for _ in self)
22
23 def is_full(self) -> bool:
24 if not self or (not self.left and not self.right):
25 return True
26 if self.left and self.right:
27 return self.left.is_full() and self.right.is_full()
28 return False
29
30
31@dataclass

Callers 2

small_treeMethod · 0.70
medium_treeMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected