3 ms·
> Sorting algorithms like merge sort are a basic example. Using recursion for those is fine. General sorting is exactly the type of thing I never use recursion
by mbell 12y ago
> Sorting algorithms like merge sort are a basic example. Using recursion for those is fine.
General sorting is exactly the type of thing I never use recursion for. Merge sort is O(n log n), sorting 100M records with a recursive implementation of it can blow the call stack in no time, depending on how you used recursion.
- nhaehnle 12y agoWhat exactly are you referring to? log 100M is roughly 27. A call stack depth of 27 has not been an issue on any general purpose system for a very long time now. Granted, there are certainly some niches left where you'd want to avoid that, but those are clearly exceptions.