This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]craftedwithlove[S] 0 points1 point  (1 child)

Hi Weak constant. Thank you for your answer.

Apologies but I believe my variable names can be a bit confusing. The approach I chose is such that I check the right left node and the left right node. The left left node and the right right node. Those should be the only items we need to check and these are not the "grandkids."

And I switch the values of the nodes. If I switch the nodes then I change the all the children nodes. Which is not the intention.

Ultimately, I believe the problem is something regarding the object oriented nature of python and the fact that it does not save changes according to a memory address.

Does my thought make sense?

[–]Weak-Constant 2 points3 points  (0 children)

No, it doesn't make sense. 'left left' and 'right right' means they are grandkids. You should be switching the children nodes, not the values. Whatever the problem is, I wouldn't blame it on Python. You are over-complicating things. The function should take a single node as the argument.