3 ms·
"merge sort or quicksort? Or maybe a binary search?" OK, but couldn't you then still complain that each of those are "Simple, shorter, no overhead from functio
by jerf 13y ago
"merge sort or quicksort? Or maybe a binary search?"
OK, but couldn't you then still complain that each of those are "Simple, shorter, no overhead from function calls, etc." as while loops?
- IgorPartola 13y agoYou might. The problem with doing a binary search in a while loop is that now you have to actually maintain your own stack, which to me seems like it should be left to the runtime. The point of using a recursion is that you can do the same thing as a loop but with less code. Mostly, the problem is that no developer in the last 10 years has ever had to write an efficient factorial function except in a job interview or for a blog post. That is slightly less the case with sorts and searches.