Open norawillett opened 1 year ago
I am also getting this... any help would be greatly appreciated!
In general when reporting error messages, it is helpful to provide the full stack trace and not abbreviate it. In this particular case, for example, you've not provided the particular line number that is causing the error, which makes it much harder to figure out what the problem is.
My guess is that the error is happening on one of the lines that mention self.root
. Recall that the insert
method is not a static method, and therefore the first self
parameter must be a BST
object. If the self
parameter is a BST
object, then self.root
will always be defined. But if the self
parameter is a Node
object (and your error message of
AttributeError: 'Node' object has no attribute 'root'
indicates that it probably is), then .root
is not defined because Node
s only have left
, right
, and value
attributes.
So somehow you have to figure out why you are calling the insert
method on a Node
instead of a BST
. The most likely cause is that at some point you were intending to call the static method _insert
on a Node
, but you called the non-static insert
instead.
Again, if we had the full stack trace here, we would be able to look at the function that is calling the insert
function in the stack trace to find exactly what line is causing the problem. But since we don't have the full stack trace, you'll have to do that part yourself.
Hello, I have finished all of the functions for the BST and BinaryTree files, however I am running into the error, and it keeps referencing my insert function:
Here is what I have for insert:
Here is my BinaryTree.py init for reference:
Anybody have any idea how to fix this?