Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you can take a problem where I'm thinking of a recursive solution as the interviewer, but you can come up with an iterative solution and explain why you think it's better, I would give you full marks.


Tell me, how many recursive functions are in your companies code base. (Or course you might not be allowed to tell; but do you know the number?)


No idea, I know I've written a few.


Thanks. How did you take tje stack size into consideration?


I would guess they'd try to use tail call recursion: https://en.wikipedia.org/wiki/Tail_call


Thats not the point. I think it is possibly harmful to focus on recursion in teaching and interviews. (Of course if the understanding is, that you do not use it in real life, then its ok, but still why not test people on skills they need for the job; its like making people jump through hoops for a swimmers position).

Of course I will be embarressed soon, when it is only me who doesnt use recursion in production. :-)


I don't know what goes on in the minds of interviewers, but if I had to guess, they use recursion to test the interviewee's ability to reason inductively --- which, of course, is necessary for writing even simple loops. Maybe a question about loop invariants might be a good replacement.

Regardless, yes, I doubt many people write a lot of recursive functions, since the data structures people use tend to either be flat, based on arrays, or neatly hidden away in libraries.


The data structures people use are choosen by people. So it is a choice to have flat datastructures (probably by people how see the diadvantages of recursion)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: