Live data from Hacker News

I Don't Want to Hire You If You Can't Reverse a Binary Tree

thecodebarbarian.com

71–80 of 115 posts

Re: I Don't Want to Hire You If You Can't Reverse a Binary Tree

#71

Sigh. If you hire using know it or not questions about binary trees, then you finally get to hire people who can study up and answer that specific question in a manner Pavlov would approve of. That does not mean the candidate will be able to design clean APIs, know how best work with different types of data, or even how to troubleshoot existing code. Still, pat yourself on the back, I mean, your entire team can answe…

The point is that this is not a "know it or not" question . You should be able to derive this answer, even if you've never seen it before, by combining things that you should have seen, because they show up all the time in CS. In the first approach he gives, you need to divide the problem into smaller subproblems, knowing that a tree is the combination of either two branches that are themselves trees or a single leaf…

...and can you reason though all of this in 15 minutes with 1-2 people staring at you?

Re: I Don't Want to Hire You If You Can't Reverse a Binary Tree

#72

ironic that his reverse function is incorrect.

Yes, he missed the base case for recursion.

Also, the first definition of symmetric tree is wrong. One more appropriate would say that the left branch is the mirror image of the right branch.

Re: I Don't Want to Hire You If You Can't Reverse a Binary Tree

#73
post #46

> "Bad programmers worry about the code. Good programmers worry about data structures and their relationships." The sizable problem with this statement is that it is using a solution to pigeonhole a person. It takes a bit of audacious hubris, something Torvalds (an extraordinary engineer no doubt) is known for, to paint an entire person and their capacity and skill into a singular and simple quote. Here's a novel ide…

You summed up everything I was thinking reading these comments good sir.

Re: I Don't Want to Hire You If You Can't Reverse a Binary Tree

#74
post #11

Earlier quoted context omitted.

That's missing the point of the article. The author says that the candidate's thought process behind arriving at the solution provides insight into the candidate's skill. There's no reason to implement your own binary tree, but knowing how to devise algorithms to accomplish a given task is a necessary competency.

Reversing a binary search tree is a binary (pun intended) answer: you either know how to do it because you learned it in college/read Cracking the Coding Interview, or you don't.

Is it not obvious that you reverse the left and right subtrees and then swap them?

I learned how to think recursively in college. I never learned how to reverse a binary tree.

Re: I Don't Want to Hire You If You Can't Reverse a Binary Tree

#77

Earlier quoted context omitted.

The point is that this is not a "know it or not" question . You should be able to derive this answer, even if you've never seen it before, by combining things that you should have seen, because they show up all the time in CS. In the first approach he gives, you need to divide the problem into smaller subproblems, knowing that a tree is the combination of either two branches that are themselves trees or a single leaf…

...and can you reason though all of this in 15 minutes with 1-2 people staring at you?

Why not?

(I get that some people have legitimate anxiety issues when placed in a situation where they're being judged and have to perform rationally under pressure. Hell, I face this every day when I think about getting customers and delivering to them. But these are worth working through on their own: there are many situations besides interviews where you will be forced to make clear & correct decisions under time pressure and are being judged on the results. The key is to focus on the thought process, not the judgment: the interviewer is irrelevant, if he doesn't like what you do go off and find another interviewer.)

Re: I Don't Want to Hire You If You Can't Reverse a Binary Tree

#78
post #47

Earlier quoted context omitted.

It's not 100% false that to use a library effectively you have to be able to write it.

"To use a library effectively, you have to be able to write it." That's a blanket statement. If we find one exception to this rule, then we can say that it's 100% false (since its truthfulness is binary -- it's either true or false). To find one exception, we only need to find a single "good" piece of software whose author can't write 100% of the dependencies, including: (probably) C/C++ compilers, FS drivers, low-le…

You're not 100% wrong but you chose the wrong examples.

Compilers & drivers aren't libraries. Low-level network libraries, using libuv as an example, have concurrency gotchas that require awareness on the part of the app developer. Using TCP as an example, think of the pain people go through over nagling.

Security software is the best example of something we use without understanding but it has gotchas; you need a nontrivial understanding of the internals to guard against sidechannel attacks.

Re: I Don't Want to Hire You If You Can't Reverse a Binary Tree

#79

Earlier quoted context omitted.

The point is that this is not a "know it or not" question . You should be able to derive this answer, even if you've never seen it before, by combining things that you should have seen, because they show up all the time in CS. In the first approach he gives, you need to divide the problem into smaller subproblems, knowing that a tree is the combination of either two branches that are themselves trees or a single leaf…

...and can you reason though all of this in 15 minutes with 1-2 people staring at you?

It is a 1 minute question, to be honest. Even FizzBuzz requires more thinking.

Re: I Don't Want to Hire You If You Can't Reverse a Binary Tree

#80
post #54
post #11

Earlier quoted context omitted.

That's missing the point of the article. The author says that the candidate's thought process behind arriving at the solution provides insight into the candidate's skill. There's no reason to implement your own binary tree, but knowing how to devise algorithms to accomplish a given task is a necessary competency.

So this article leads off with @mxcl's tweet about google not offering him a job because he wasn't able to reverse a binary tree on a whiteboard . I don't think that being able to describe an algorithm you haven't had to implement in more than decade (at least, that would be the case for me, college is starting to be a long time ago for me). Honestly right now, without looking up the answer, I probably can't reverse…

Deriving trivially provable algorithms in a test-driven way, by trial and error, hoping that no edge cases are missed? Sounds really, really depressing. The future of software engineering is very bleak if this approach is a new norm.
Post reply on HN