Hacker News new | ask | show | jobs
by bajsejohannes 1900 days ago
Unpopular opinion, maybe, but:

I don't really get why "reversing a binary tree" seem to be used as an example of what's wrong with hiring. I will say, though, that if someone said "how do you reverse a binary tree?" I would have asked the follow up question: "what do you mean by that?". If asking that would be used against me, sure, that's bad hiring.

But if the answer is: "swap all the left and right nodes in a binary tree", then... isn't that pretty basic programming?

2 comments

It's funny, I've heard "reverse a binary tree" as the canonical coding interview algorithm question for over a decade and I've never stopped to think about what it actually involves. But I just Googled it and it seems like you're right...and yeah I feel like if you know how recursion works and you know what a decision tree is, it seems like a pretty trivial question.
It's a common joke interview question. I don't think anyone has acutally asked it?

I find high end jobs tend to ask some form of problem that can be tackled using dynamic programming techniques. Maybe couple of easier ones in the first interview.

I agree with most people. I never use these skills in the job. I think they're a intelligence test in disguise.

Oh, if it's just a joke that went over my head then that totally makes sense! Though in fairness there are apparently-serious interview questions that are even easier (e.g. FizzBuzz, though I don't think anyone asks that anymore either) and I've been asked interview questions that aren't much harder.

I mostly agree with your impression, though even after adjusting for intelligence I bet there's a positive correlation between knowing how B-trees work and, say, having a good intuition for how to index a database.

For me, the 'reverse a binary tree' question goes back to the creator of Homebrew being rejected from Google for not being able to answer that question: https://twitter.com/mxcl/status/608682016205344768?lang=en
Why would you even want to reverse a binary tree in the first place? Simply traverse it backwards, it's just as fast.
Maybe you’re passing it to some other function that doesn’t do that, or you don’t want to add some ordering flag to the datatype because that complicates things.

But the purpose of the question of course is to be an easy question showing basic competency in recursion and pointer usage.