3 ms·
You 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
by IgorPartola 13y ago
You 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.