I am working on a heap structure.
Whenever I added 10 or more nodes to the tree, for some reason the data switches from a node to a None
type.
def _FindLast(self,root,index,node_count):
if root is None or index>= node_count:
# print(f"this is the temp in none {type(root)}")
return None
if (2*index+1 == node_count-1):
# print("return left")
print(f"this is the type from left {type(root.left)}")
temp = root.left
root.left = None
# print(f"this is the temp type{type(temp)}")
return temp
if (2*index+2 == node_count-1):
# print("return right")
print(f"this is the type from right {type(root.right)}")
temp = root.right
root.right = None
return temp
left_results = self._FindLast(root.left,2*index+1, node_count)
# print(f"the type from {type(left_results)}")
if (left_results is not None):
# print("yes")
# print(type(left_results))
return left_results
return self._FindLast(root.right,2*index+2,node_count)
I really don't get why I have added the method above.