posted 8 years ago
I've got something that's been bugging me. For this binary tree deleteNode function, when a node is found, the method deleteFromTree is called on it. I understand everything, except: this may sound silly, but it seems that the method passes the target node on in a roundabout way. As you see, when found == true, we don't simply pass current as the method parameter, but rather tempCurrent.lLink or tempCurrent.rLink. Why is this? I know that there must be a reason that I'm not seeing (my text surely doesn't do it just for the heck of it), but it seems that this wastes computing time creating a reference to tempCurrent, then comparing it to deleteItem, then passing the appropriate child of tempCurrent to the deleteFromTree method, when current could simply be sent as the parameter, as it is the target node upon found == true. Thanks in advance!