I was trying to make this binary search tree and was defining its recursive get function. But no matter what i do it always returns None. I m just a newbie... So sry if the solution is obious or something... But please can anyone tell me why is it returning none value...???
def get(self,key):
if self.root:
res = self._get(key,self.root)
if res:
return res.payload
else:
return None
else:
return None
def _get(self,key,currentnode):
if not currentnode:
return None
elif currentnode.key==key:
return currentnode
elif key<currentnode.key:
self._get(key,currentnode.leftchild)
else:
self._get(key,currentnode.rightchild)
I am using a dict at each node with the key being the comparison parameter...