I just recently got done with my own implementation of a binary tree, which works pretty well for a first attempt I think. I can add left and right children to a root node fairly easily, view a node's value, as well as verify if a certain node is a child or not.
However, I do have a problem with a search function I have, which calls upon a Pre-order traversal system. In my IDE, using a binary tree like so:
attempting to use my search function constantly returns the error "AttributeError: 'int' object has no attribute 'data'", which I'm not particularly sure what it means. In my code here:
def search(self, value):
def find(x):
if x.data is not False:
return True
val2 = self.traverse_pre_order(find)
if val2 is not True:
return False
else:
return True
I attempted to change x.data to simply x, but this returns me the AttributeError 'NoneType' object has no attribute 'traverse_pre_order'.
I've attatched a link to PasteBin with my full code relevant to the Binary Tree I'm working on.
