Im having a problem with python.. I have a binary tree node type:
class NODE:
element = 0
leftchild = None
rightchild = None
And I had to implement a function deletemin:
def DELETEMIN( A ):
if A.leftchild == None:
retval = A.element
A = A.rightchild
return retval
else:
return DELETEMIN( A.leftchild )
Yet, when I try to test this on the binary tree:
1
/ \
0 2
It should delete 0, by just setting it to null but instead, i get this:
0
/ \
0 2
Why can I not nullify a node within a function in python? Is their a way to do this?