I programming Kdtrees with Python 3 and I have an issue with the function that is aimed to determined whether the node put in the arguments is in the Kdtree.
I use a recursive function but it returns None even when the point is present.
#I put the init to show you how the kdnode is made
class KdNode:
def __init__(self, point, dim, left_child, right_child):
self.point = point;
self.dim = dim;
self.left_child = left_child;
self.right_child = right_child;
def KdTree_present(kdnode,point_to_test):
if kdnode == None:
return
else:
KdTree_present(kdnode.left_child, point_to_test)
KdTree_present(kdnode.right_child, point_to_test)
if kdnode.point == point_to_test:
return True
#Kdnode_example = [(150, 300), 1, [(200, 250), 0, None, None], [(325, 400), 0, None, None]]
Even the output of KdTree_present has to be True, it is always None.