r/programming • u/SilasX • May 09 '15
"Real programmers can do these problems easily"; author posts invalid solution to #4
https://blog.svpino.com/2015/05/08/solution-to-problem-4
3.1k
Upvotes
r/programming • u/SilasX • May 09 '15
2
u/Silhouette May 09 '15 edited May 09 '15
I think this is what can make even simple Fibonacci-related questions quite informative for the interviewee as well. If the interviewer leads the discussion towards recursion vs. iteration, you can follow up in several different ways to find out useful information about both the interviewer's own technical skill and the kind of recruitment strategy the potential employer uses. These may give a strong indication in either direction about whether you really want this job.
For example, if the interviewer suggests a little too casually/generally that recursion is inefficient and iteration is better, you can introduce tail recursion to the discussion and suggest that a tail-recursive form could also achieve sensible performance. This can lead the discussion towards code generation, the performance and reliability implications of using tail-recursion in different programming languages, the importance of understanding your tools and choosing among different programming styles, and so on.
Another possibility is to consider the underlying mathematical recurrence relation and derive a closed form for the n-th Fibonacci number. You can tell a lot from how your interviewer reacts to this third possibility. Assuming they understand what you're doing (if you just caught out a non-technical interviewer, the next part isn't really worth pursuing in my experience) then you can talk about when it might actually be worth using that sort of solution in practice, given the likely overheads of calculating with floating point vs. integer arithmetic. Again this can get you into a more nuanced discussion about performance and how to choose good algorithms in realistic situations.
If you push out in either or both of these directions and your interviewer goes along with you, you'll quickly both establish that the other one has some idea of what they're talking about, and hopefully move on to more interesting questions having established a level of mutual respect.
On the other hand, if the interviewer doesn't go along with you, then either they are technically incompetent themselves, or they are stuck with some sort of rigid interview playbook that is more about ticking boxes than actually having a two-way discussion to figure out whether the candidate and business are a good fit. Either way, wrapping up the interview early and looking for other options is usually indicated.
Edit: Rewrote mathematical paragraph slightly to avoid somewhat misleading discussion of complexity.