6 ms·
I can agree with Jonathan Blow's responses in so far that you should be able to invert a binary tree in an interview if that's the sort of knowledge you need on
by always_good 9y ago
I can agree with Jonathan Blow's responses in so far that you should be able to invert a binary tree in an interview if that's the sort of knowledge you need on-call on the job and there's somehow no room for rustiness because it's some sort of high stress environment that needs immediate results (btw that doesn't describe jobs at Google).
But then he reveals that he's completely full of himself when he suggests that "sorry, you're not a good programmer then."
- opmac 9y agoThe name "Jonathan Blow" and the words "full of himself" pretty much go hand-in-hand.
- tomp 9y agoHaha, I've been a programmer for most of my life and I don't know what "inverting" a binary tree even means!
- guessmyname 9y ago2 2 / \ / \ / \ / \ / \ / \ 1 3 3 1 / \ / \ / \ / \ 0 7 9 1 reverse >>> 1 9 7 0 / / \ / \ / \ / \ \ 2 1 0 8 8 8 8 0 1 2 / \ 7 7
- hinkley 9y agoThat’s reversing a binary tree.
- guessmyname 9y agoInverting == Reversing [1] [1] https://leetcode.com/problems/invert-binary-tree/description/ https://leetcode.com/problems/invert-binary-tree/description...
- nathan_f77 9y agoThat was fun, thanks! I remember reading that tweet a while ago, and "inverting a binary tree" sounded very complicated, but it's really just one line of code.
- hinkley 9y agoThis problem was inspired by this original tweet by Max Howell There are many definitions of invert. This is relying on one definition that is jargon, and not widely agreed upon jargon at that. For a two or more dimensional “object”. Invert means to reorient the top and the bottom, while reverse swaps the left and the right. The two only might mean the same thing with one dimensional data structures. For instance inverting a line of text might (ambiguously) mean reversing it. Or drawing it upside down. Or upside down and backward. But at least you would expect a clarification.
- mullen 9y agoWhy would you want to reverse/inverse a binary tree?
- sushid 9y agoIt's an easy way to check if you can think recursively/are familiar with a btree.
- tomp 9y agoAh, I would personally call that "flipping", I kind-of imagined that "inverting" would mean maybe taking a node and putting in the root of the tree or something similar...
- nnd 9y agoI'd be very careful now, you might not be a REAL programmer.
- johannes1234321 9y agoFor writing non-trivial software basic knowledge of data structures is needed. Especially with performance requirements like Google has. In some areas you get away without such knowledge but if you bild a dependency management tool like brew and don't know what a tree is, this is suspicious. In the interviews I did with Google, Facebook and others (mostly for fun, not profit) if I didn't know an algoithm from top of my head I typically could talk to the interview and discuss th problem and they'd point me in the direction. Sometimes those interviews are less about being able to remember the thing, but the thought process to get there. Aside from that: Google clearly optimizes on not hiring too many bad people, but rather leave a few good candidates behind.
- always_good 9y ago> if you build a dependency management tool like brew > and don't know what a tree is, this is suspicious They didn't say that they didn't know what a tree is. They said they couldn't invert a binary tree in the interview. It's a stretch to start suggesting that someone doesn't know their basic data structures because they failed some riddleware on the spot. You can say that they aren't what google was looking for, but my problem comes when someone tries to dismiss another as a bad developer because of that.
- johannes1234321 9y agoWell, inverting is a trivial operation, pseudo-implementation: swap(left, right); recurse(left); recurse(right); If one doesn't know what is meant one can talk to the interviewer and get a hint about what is meant. It can be that the interviewer is bad and misleading, but usually they have some specific training, this seems unlikely as the candidate didn't complain about the interviewer but admitted he had no clue. The follow-up question would probably be the question about the complexity, that is also trivial f you know fundamentals of big O notation, as one has to walk over each node. It's hard to find a more trivial algorithms question. Algorithms are fundamental knowledge for programmers (other than script kiddies)
- innocentoldguy 9y agoIsn't the typical practice amongst software engineers, when you don't know something off the top of your head, to cut and paste from StackOverflow? Why do we need day-long job interviews and whiteboards to ascertain that?
- deleted 9y ago[deleted]