+ 10

Sorting algorithms

Why using multiple sorting algorithms? If I understood correctly main difference between them is in speed. So why not use fastest one all the time? Is there another factor other than speed?

5th Dec 2017, 9:04 AM
Elva
Elva - avatar
5 ответов
+ 11
✓✓easy way ✓✓with iteration counter ✓✓running time of algorithms ✓✓please check this once https://code.sololearn.com/cY7SC8lmidwy/?ref=app
7th Feb 2018, 6:03 PM
ASIF BILAKHIYA
ASIF BILAKHIYA - avatar
+ 10
@Elva, thank you for make my answer as best!! 😊😊 👍👍
14th Feb 2018, 8:13 PM
ASIF BILAKHIYA
ASIF BILAKHIYA - avatar
+ 5
definitely speed is a factor. And they are not useful on every type of input. suppose you have 2 elements in a list. binary search may not be a good exqmple because it will take more time to declare high & low. Instead a linear search would be way more useful. Now if you have 200 or 2000 elements then the time taken by declaring high & low will decrease time taken to search.
5th Dec 2017, 9:45 AM
shobhit
shobhit - avatar
+ 5
Here is an example: https://code.sololearn.com/cMrvFWe4Cb9J/?ref=app Notice how the slower bubble sort is actually more efficient for a smaller sized array.
6th Dec 2017, 8:06 AM
bornToCode()
bornToCode() - avatar
+ 1
sorting algorithms are described in cases: best, worst. Sometimes it is better to have a constant complexity (best = worst). for example in medical devices you choose a maybe slower algorithm if the worst case is faster. In very tight timed applications it is often good to know/estimate how long it will take, instead of being fast on one case an slow on another. in some szenerio you are good to be fast in good cases and you don't care about worst cases (like on a website, you want to make it as fast as possible but normally user accept it if it lacks sometimes)
6th Dec 2017, 9:29 AM
Gunther Strauss
Gunther Strauss - avatar