Hacker News new | ask | show | jobs
by hardlianotion 778 days ago
What is inverting a binary tree? I don't think I have ever known what that means.
1 comments

You can find the problem described here. It also has a link to solutions in different languages.

https://leetcode.com/problems/invert-binary-tree/

So, inverting is just swapping the left and right pointers for the entire tree? Why would you ever do that? That will flip the ordering of the tree and none of your search or balancing functions will work anymore. Shut up! Don't ask questions! Uh, ok.
Oh thanks - I forgot I asked this! So an efficient way to invert would be to abstract out the ordering relation and make it swappable.