You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Apparently you took it that way. I mention 30 items and you post something about 10,000 items.
The best case is that insertion sort will save nanoseconds compared to quicksort (e.g. array of 10 items), and the worst case is that it will be whole seconds slower (e.g. array of 10,000 items), as in the benchmark I attached.
The only good time to use insertion sort is a scenario where you know that you are dealing with an array which will never, ever, ever have more than 10-20 items. Those cases are vanishingly rare. Even if you think that you will always be dealing with a small array, the downside in nanoseconds of using quicksort is preferable to the possible consequences if your assumption turns out to be wrong.
This is the sort of scenario where you would otherwise be saying to people "Do NOT use insertion sort, EVER. For ANY Reason."
I've also found it much cleaner to encapsulate your functions by deriving your own collection class.
Doesn't add anything but I post for completeness your code that I bent to fit my situation