Binary tree problem (searching)
akameswaran at gmail.com
akameswaran at gmail.com
Tue Apr 4 17:27:19 EDT 2006
This took a moment
I spent a lot of time stupidly thinking about right/left sorting, is it
looping? no that's not it...doh Then the light
then realized this
if self.key == key:
return 1
elif key < self.key:
if self.left:
self.left.find(key)
else:
return -1
you need to RETURN on the child call -
if self.left:
self.left.find(key)
becomes
if self.left:
return self.left.find(key)
More information about the Python-list
mailing list