TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Dissecting an interview question

67 pointsby bratfarrarabout 11 years ago

21 comments

Jemaclusabout 11 years ago
The &quot;haters&quot; section leaves out one critical reason for not doing something like this that I think is quite relevant. For those of us who have never had to do a BST before (I do not have a degree in CS, though I&#x27;ve been coding professionally for 8 years), expecting us to solve a BST problem in the 10, 15 minutes alotted is not really great. Even if I&#x27;ve never seen it before, the idea that I can solve it in 15 minutes in a high pressure environment is unrealistic.<p>In a real world scenario, if I had to solve this kind of thing, I&#x27;d rely on existing works first. I&#x27;d google the problem, and I&#x27;d see what solutions are out there. For <i>most</i> problems, there&#x27;s <i>something</i> that can point me in the right direction.<p>For solving a BST issue from scratch in 15 minutes, well.. let&#x27;s just say the first guy to come up with BSTs probably didn&#x27;t come up with his solution in 15 minutes.<p>So I would give it my best shot, but if I don&#x27;t succeed, you shouldn&#x27;t hold it against me. I disagree with the premise that if I can&#x27;t solve this, I can&#x27;t solve novel problems. That&#x27;s just blatantly incorrect. I solve novel problems every day -- just not on a whiteboard and not in 15 minutes.<p>I would <i>much much much</i> rather see a real-world problem. Something you&#x27;ve actually run into. For instance, in my line of work, I deal a lot with addresses. One of the issues that I&#x27;ve had to solve in the past is parsing addresses. If I give you a string of &quot;123 Main St, Boston, MA 02123&quot;, how do you break that up into street, city, state, zip?<p>That&#x27;s something I&#x27;ve actually had to solve. It&#x27;s something that anyone with critical thinking skills can take a decent shot at in 15 minutes. A binary search algorithm? I got a question like this one time, and I floundered because I got 90% of the way there, but I couldn&#x27;t figure out how to solve one of those edge cases. The guy basically ended the interview right there, but I asked for the solution. When he gave it to me, it was something straight out of an academic textbook.<p>I said, &quot;Oh, you guys must use binary trees a lot.&quot; And he laughed and said, &quot;No, never. It&#x27;s low-level stuff for databases.&quot;<p>And I just sat there, dumbstruck. Why would you give me a problem that you&#x27;ve never had to solve yourself?<p>I dunno. I just disagree with the premise of the article. I think there are far better questions to ask. Problem solving in general is required -- solving academic exercises much less so.
评论 #7423890 未加载
评论 #7424228 未加载
angersockabout 11 years ago
The thing I particularly like about this is that the problem spec is very rigid and clear: no generic solutions (ints only), don&#x27;t worry about balancing, don&#x27;t worry about visibility, make it work, and then they give example usage of the API.<p>It&#x27;s really easy to screw up a one-page toy problem spec: I&#x27;ve done that myself, and got many replies that failed to either follow the spec or failed to identify ambiguities in it. Having a simple problem as a baseline is really helpful.<p>That said, what I <i>don&#x27;t</i> like about this is that it doesn&#x27;t really test the candidate&#x27;s ability to reason about systems or architectural things--then again, as a better &quot;fizzbuzz&quot;, this seems to fit perfectly.
shalmaneseabout 11 years ago
How many of the candidates you interview start off by writing simple test cases to make sure they&#x27;ve thought of all the edge cases before they dive into coding?<p>Have you noticed any correlation between the test-first people vs develop-first people?
评论 #7424394 未加载
danesparzaabout 11 years ago
[sarcasm]Please continue to use this question. It’s a wonderful marker for candidates (like me) who don’t want to work with folks who think questions like that are useful.[&#x2F;sarcasm]<p>To be honest, I think it’s far more interesting to set aside a real world problem that you have encountered at your company and see how a candidate would think through it (out loud, of course). Many issues you’ll need to solve on a day-to-day basis have nothing to do with programming — and instead have to do with knowing related technologies (like a TCP&#x2F;IP network, or a database) and how they interact.<p>You might be shocked to discover how many developers have a deep understanding of algorithms but can’t troubleshoot&#x2F;design&#x2F;architect&#x2F;solve their way out of a paper bag.<p>Also: the thought of you ACTUALLY chewing your arm off is morbidly humorous. Thanks for that. :-)
评论 #7422980 未加载
评论 #7423210 未加载
评论 #7423765 未加载
评论 #7422792 未加载
评论 #7423219 未加载
评论 #7424842 未加载
评论 #7422939 未加载
ollysbabout 11 years ago
We do a quick phone call screener and then do some pair programming. We only do half a day of pairing (for which they&#x27;re paid for) but I find that this is the perfect place to do a stealth interview with the candidate. They feel comfortable because they&#x27;re in their daily environment (we do it remotely using floobits, so they&#x27;re sitting at their usual desk with their usual apps etc.). Here you can get a really good conversation going about things that are actually relevant to the job. Anything else just seems like guessing now.
gumbyabout 11 years ago
I find the responses so far on HN quite interesting. The author of the article is pretty clear, but still, people question the appropriateness or whether it&#x27;s passive aggressive.<p>What you want to know from a programming question is: - have you actually written code and can you still do so? - do you have a &quot;feel&quot; for how the code works or are you a cut &#x27;n paste person? - do you know &quot;enough&quot;<p>(the last is elusive: it&#x27;s like being able to calculate in your head: sure, I use a calculator, but I can tell when I see the result if I&#x27;ve made a key press error along the way because I have a rough idea of what the answer will look like.).<p>And this is another reason not to sweat the small stuff. The odd lost semicolon is no big deal; not knowing the difference between recursion and iteration is.<p>&quot;Real&quot; problem are rarely bite sized. Plus the interviewee won&#x27;t have enough context to know which parts of the problem statement are significant and which aren&#x27;t. Much better to provide something simple and abstract that only takes a couple of lines to answer.<p>Another good starter question is &quot;make a deck of cards however you like and shuffle it.&quot; An amazing number of people feel this is under constrained and ask for more definition. I don&#x27;t care about the implementation of the deck (integers mod 13 for face and divided by 4 for suit work OK, or you could define an object). It&#x27;s surprisingly common that people just make a complicated copy or inverse than an actual shuffle.<p>One guy reversed the deck and when I gently asked if it was actually random laughed out loud, smacked himself on the forehead, rubbed out a bit of brain damage on the whiteboard and put a random() in. He turned out to be an awesome programmer. No way did I want him to feel bad about making a silly mistake. He knew how to solve that (and a couple of other problems).<p>A little problem like this supplies plenty to talk about (what if we did this? How would you deal with this scaling up) to show the interviewee how we think about things and vice versa.<p>As for the address problem: it is basically a huge set of special cases. That&#x27;s a different kind of problem and not actually a programming question.
danbrucabout 11 years ago
I put this first, because that is why I started writing this comment. I have to disagree with some of judgments made by the author. The first one is debatable but usually you don&#x27;t want duplicates in your binary search tree - I consider all the example implementations broken. But he really lost me when he started talking about the coding style. The given example is not perfect but I consider it better then most of the other examples when it comes to coding style - if and else without braces, if with break but without else. Everywhere. It is a lot of religion, it is a lot of personal preferences, but all the more it seems really wrong to judge more on personal preferences of style than on correctness and other hard facts.<p>And here what should have come first. I think this is a relative unrealistic task because writing your own data structures is quite a rare task for most programming jobs. Nonetheless it is a very basic task and every professional developer should be able to get this right within 15 to 30 minutes.
thebossabout 11 years ago
&gt;Top candidates<p>If they are top candidates, why are you asking them to solve a problem that might as well be copied directly from a college text book?<p>&gt;my version of fizzbuzz<p>How many times do you write a for&#x2F;while loop a day when programming. A lot. How many times do you implement a full BST a day. I&#x27;d guess about 0.
detrinoabout 11 years ago
A quick C++ implementation: <a href="http://ideone.com/hGtbts" rel="nofollow">http:&#x2F;&#x2F;ideone.com&#x2F;hGtbts</a><p>While this was easy to do in ~10 minutes using gedit&#x2F;clang&#x2F;valgrind, I have to wonder how well I would have done had I been forced to use a whiteboard.<p>&gt; Even if you haven’t studied or used BSTs in a while – even if I have to explain them to you on the spot – you should be able to complete the problem without much difficulty.<p>I agree with this statement if you have access to a minimal development environment, but not on a whiteboard, which is entirely unforgiving to making any changes. In the end, this serves only to select candidates who know <i>exactly</i> how to solve <i>this</i> problem beforehand.
gameguy43about 11 years ago
I dig this problem. One thing it doesn&#x27;t touch, though, is the importance of using descriptive variable names to organize your thinking (in this case the var names are kind of a given--left, right, node...&quot;current&quot; is the only one someone might find a useless name for). I&#x27;ve found the candidate&#x27;s ability to choose descriptive variable names is strongly correlated with general organization and clarity of their thinking.
kstenerudabout 11 years ago
Generally, when it comes to coding, I&#x27;ll ask the interviewer if we can just do it on my laptop in a real development environment. Nobody actually codes on a whiteboard, so why should it happen in an interview? I want to play with the code, reason about it, refactor it as my understanding of the problem space expands. I can&#x27;t do that on a whiteboard.
评论 #7427674 未加载
spinlockabout 11 years ago
My problem with whiteboarding anything other than pseudo code is that I&#x27;m pretty dyslexic and I&#x27;ve spent years learning syntax at the keyboard. That learning does not translate to the whiteboard. To give an example of how much the presentation of problems matters to me, the first time I took the GREs I got a 340 on the verbal. The problem was that I had practiced out of a book not on a computer. The second time I to the GREs I scored a 740 on the verbal because I spent the time to learn how to take the test.<p>Anyway, I don&#x27;t have the time to learn how to program on the whiteboard. I also don&#x27;t think it&#x27;s a valid signal of how well I can program at a computer.
agentultraabout 11 years ago
Isn&#x27;t the optimal strategy for an interviewee to game the system? There are groups like <a href="http://codingforinterviews.com" rel="nofollow">http:&#x2F;&#x2F;codingforinterviews.com</a> where you can find a set of classic and popular problems to memorize. Interview in rounds and refine your problem set.<p>As interviewers... is this what you&#x27;re looking for? What are the selection criteria after this then?
评论 #7425035 未加载
lzhouabout 11 years ago
So the old - allocate a massive array, then use 2n+1, 2n+2 for the left&#x2F;right children wouldn&#x27;t have flown with you huh?
评论 #7423241 未加载
评论 #7423146 未加载
namelezzabout 11 years ago
Dude, you lost me when you consider &quot;Switching the left and right sides&quot; a critical mistake. It&#x27;s an interview. Candidates can be very stressful and make mistakes easily. Also you are interviewing a human not a machine.
mcguireabout 11 years ago
* One class v1<p><pre><code> public class BST { private BST left, right; private Integer value; } </code></pre> &quot;<i>All of the above are valid answers....</i>&quot;<p>Wait, wait, wait. That one can&#x27;t be empty.
评论 #7422896 未加载
评论 #7422897 未加载
hackdaysabout 11 years ago
As daunting and necessary interviews and phone screens are , there is one thing that&#x27;s surprisingly not used enoughto vet a candidate - Referrals.<p>At <a href="http://referralhire.com" rel="nofollow">http:&#x2F;&#x2F;referralhire.com</a> we are adding that important data point to your hiring process. To have a person referred by an accomplished developer is extremely valuable and is something that cannot be judged in an interview. It will also help avoid a lot of false negatives! Very talented developers we have met were rejected at multiple interviews just because of the interview day performance.<p>All companies need to start using this more in their candidate search and decision making process.
评论 #7427724 未加载
collywabout 11 years ago
Why would you implement a binary search tree in any of those languages. There are likely to be well written, tested, optimized libraries out there for that sort of thing.
评论 #7429328 未加载
mrfusionabout 11 years ago
I&#x27;ll bet he ends up with a lot of employees who are great at writing BST&#x27;s. Are they great at solving the problems his business faces? Who knows?
codrabout 11 years ago
Indeed time to retired it - it&#x27;s really not a creative question, nor will show how creative the candidate is.<p>While I&#x27;m all for testing the bounds of a candidate&#x27;s CS knowledge, try to come up with an original problem that nobody has asked before!<p>You can get a lot of mileage out of doing stuff like reversing numbers (without using strings), etc.
bratfarrarabout 11 years ago
Time for BST code golf - winner does it in the fewest characters!
评论 #7424186 未加载