forked from TheAlgorithms/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkd_node.py
30 lines (25 loc) · 938 Bytes
/
kd_node.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from typing import List, Optional
class KDNode:
"""
Represents a node in a KD-Tree.
Attributes:
point (List[float]): The k-dimensional point stored in this node.
left (Optional[KDNode]): The left subtree of this node.
right (Optional[KDNode]): The right subtree of this node.
"""
def __init__(
self,
point: List[float],
left: Optional["KDNode"] = None,
right: Optional["KDNode"] = None,
) -> None:
"""
Initializes a KDNode with a point and optional left and right children.
Args:
point (List[float]): The k-dimensional point to be stored in this node.
left (Optional[KDNode]): The left subtree of this node. Defaults to None.
right (Optional[KDNode]): The right subtree of this node. Defaults to None.
"""
self.point = point
self.left = left
self.right = right