I would like to mention that this is a homework but am not asking for help related to code.
I am having this strange problem . I am trying to implement a btree deletion and am having some recursive return problem
def delete ( tree , node , value ) :
if node.leaf == True:
# delete value from node
return tree
elif node.leaf == False and value in node:
# do other stuff
else :
delete(tree,node.Child,value)
#recurse till you find leaf node
This is just a pseudo code as I can’t post my entire code here. The problem coming is that
when I write delete(Tree,Tree.root,value) it runs first time recurses and executes the leaf node portion but returns me a None value.
I have checked out everything and even printed stuff just above the return tree statement and it is fine with tree having some value up till there.
Can anybody tell me what am I doing wrong in this recursive function….
Thanks a lot..
A quick guess, fix to to:
And I guess you should recurse into all children of the node, not only one (there might be more than one, right?).