Hacker News new | past | comments | ask | show | jobs | submit login

Right. I learned what binary trees were in college and didn't directly use them much afterward. Since interviews sometimes ask about trees, I started my practice of solving tree problems by practicing how to invert a binary tree. I practiced it so much that I can invert a binary tree from memory now, so that I won't get bounced from an interview like the inventor of Homebrew was from a Google interview.

Most of the concepts I learned, although I don't remember learning Kadane's algorithm for solving the maximum subarray problem in school, so I've learned some things like that. I can also implement a solution for an associated Leetcode problem in one line of code, so I wound up memorizing that too.

OP says "If you master the methods and ideas, you should be able to derive the answers on the spot", but I hear from a lot of people that does not happen, even (implicitly) in this thread. Any how, even if I use OPs method, if I do the same problem over and over and over again I'm going to wind up memorizing it any how.




Learning is like nutrition. There is no ”one true way", instead there are lots of people and each one has their own approach to learning.

Some people are closer to each other, and upon realizing that they believe they've found a pattern. But it's like when people tell you that you need to supplement x in your diet. It's possible that x helped you. And it's even possible that you'll find other people with the same nutritional deficit, creating the illusion that everyone would benefit from supplementing. But that's just what it is: a premature extrapolation from anecdotes


> [...] so that I won't get bounced from an interview like the inventor of Homebrew was from a Google interview.

Just for the record, that never actually happened. It's just a thing the homebrew guy made up.

(I know, the rest of your points are unaffected by this. I just feel annoyed when we casually warm up old myths.)


He admitted to lying about it? Do you have a source for that? I couldn't find anything.


I was at Google when that happened, and had some inside sources (ie gossip from the guys who interviewed him, who said they didn't even ask any tree questions, and memegen).

I tried to find some outside sources, but nothing about Howell admitting his 'artistic license' outright. So take my fallible memory with a large pinch of salt.

See https://news.ycombinator.com/item?id=15713801 for some discussion, and to see how 'invert a binary tree' wasn't even an established term that anyone at Google would have used.


What is inverting a binary tree? I don't think I have ever known what that means.


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: