Live data from Hacker News

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

thecodebarbarian.com

81–90 of 115 posts

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

#81
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.

What? You do not need to know anything at all. The very wording of this problem is already a solution. No thinking required. No prior knowledge required.

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

#82
> By the time I get to the whiteboard stuff, I'm looking for someone to want to engage with me, not an attempt to stump them.

Dredging this comment, because while this article is not about whiteboard coding, it would inevitably be mentioned.

I think many people, including many interviewers, completely miss the point of whiteboard coding. I think this article needs to be shared: http://darrenkopp.com/posts/2013/04/19/Post-mortem-of-my-fai...

The key point is that the interviewer is, or should be, a friend. He should not be out to stump a person or out to get him; he should genuinely want a person to succeed at the interview. If not, it's better just to reject the person outright. White board coding should be seen as a way for person to engage in collaborative problem solving, which is something that we do on a daily basis. Can you explain your thought process? Can you admit your stuck? Can you have an intelligent discussion about your solution, listen to feedback, etc. The problem should be challenging and relevant, but it should not be a test of coding skill.

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

#83
These questions shouldn't be asked expecting an exact solution in the whiteboard, this adds layers of stress and time. They should be asked expecting an explanation of how they work conceptually. You want to see if the person understands the methods used to traverse, sort, manipulate them. Are they important?, of course.

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

#84
post #22
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.

> knowing how to devise algorithms to accomplish a given task is a necessary competency Agreed. Why not use a realistic problem and setting?

Because realistic problems tend to be far bigger than the small, fundamental building blocks.

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

#85
post #28

Earlier quoted context omitted.

Well, to pick on Valeri, this is simply wrong Trees are the single most important data structure in computer science. Just about everything you do in your programming career will be related to trees. Trees are a horrid data structure for any modern processor. Pointer chasing thrashes caches. The actual most important data structure is a hashmap. The same speed in theory, much faster in practice.

Everything in programming is trees. If you write a program that calls functions, that call other functions, that's a tree.

I believe continuation-passing style is an alternative to the direct style you mention. Return-oriented programming and threaded programming may be specific counter-examples.

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

#86
post #64

Earlier quoted context omitted.

How is that a "trick" question? I never been asked that in an interview question and had the correct solution in my head in just a few seconds for the very reason he gives -- experienced programmers can map their intuition to code. This is certainly a skill that takes time to develop, and if you're concerned with hiring the best, don't you think this is a decent heuristic to throw in with a bunch of others ? Programm…

> Programmers are so sensitive, and honestly all your "sighing" is obnoxious. Perhaps instead of being annoyed, you could try to understand why people are sighing. Many of them will have lost out on a job they were qualified to do because of bullshit interviewing practices like this one. It has a real effect on them. It's not a trivial issue. > You don't have it all figured out. No one here has claimed to have it all…

I'm actually not annoyed nor do I misunderstand why people are sighing. Your emotional appeal does not hold much weight when faced with real business practices of hiring "the best" that every organization is going to strive for.

I'm somehow a poor boss to work for because I told the OP his sighing is obnoxious? It is. It feigns authority and condescends the entire post for being so dumb he has to sigh at it. While you might have your feelings hurt, have you considered the feelings of the guy who took the time to write up an entire post explaining his position in a rather civil & straightforward manner? Have you considered the person at the other end of the interview table?

> No one here has claimed to have it all figured out

> whiteboard interviews are terrible, alienating, unrealistic, antiquated tools for hiring.

Hm...

And ya man, I'm not a programmer but I figured out his coding puzzle in a few seconds.

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

#87
post #38
post #28

Earlier quoted context omitted.

Well, to pick on Valeri, this is simply wrong Trees are the single most important data structure in computer science. Just about everything you do in your programming career will be related to trees. Trees are a horrid data structure for any modern processor. Pointer chasing thrashes caches. The actual most important data structure is a hashmap. The same speed in theory, much faster in practice.

How do you represent hierarchical data in a single hashmap?

Depending on your problem domain, you might be able to flatten it by just combining keys together (subject to keys being combinable like with string concatenation, using separators to ensure uniqueness of combined keys, etc.)

E.g., turn {"foo": {"bar": "moop"}} into {"foo-bar": "moop"}. This also requires writing accessor fns, but it might be worth it, depending.

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

#88
post #28

Couldn't disagree more with the author. How many developers need to implement their own binary-tree? This is why code-bases become convoluted with six different implementations of standard data structures.

Well, to pick on Valeri, this is simply wrong Trees are the single most important data structure in computer science. Just about everything you do in your programming career will be related to trees. Trees are a horrid data structure for any modern processor. Pointer chasing thrashes caches. The actual most important data structure is a hashmap. The same speed in theory, much faster in practice.

You do not need to represent a binary tree as a structure with two pointers. See how a typical Huffan tree is implemented, for example.

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

#89
post #2

I lost him at: "I think homebrew is an awful piece of software that should never be used by anyone."

He clarified in the comments:

> I just couldn't resist a chance to take a snipe at homebrew, because I've spent more time than I care to admit sorting through the mess junior devs, designers, and non-technical people make of their dev machines with homebrew and when it comes time to upgrade everything inevitably goes horribly wrong.

The comment implies that real developers do not use Homebrew.

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

#90
post #43

> "Just about everything you do in your programming career will be related to trees." I've never knowingly used a tree structure since college, everything is abstracted away from me. Now whether this is a good thing or a bad thing remains to be seen, but it has not been a problem yet.

Have you ever stored a dictionary inside a dictionary? (e.g. something like the JSON: {foo : {bar : "baz"}} That's a tree.

...unless it's a hashmap inside a hashmap. Or named fields in an object holding pointers that use no keys after compilation.

The point being that hierarchical structures in programming languages abstract away from the underlying representation, and you can use them without knowing the details. (Though you should probably know anyway, so you understand your Big-O tradeoffs.)

Post reply on HN