+ 5
What is the best sort algorithm you know?
Please helppp, need to make a homework for tomorrow! Thanks a lot!
5 odpowiedzi
+ 3
bubble sort is an algorithm. I don't get the question. Do you mean what's the fastest sorting algorithm?
It really depends on the array / how the data is distributed.
Quick sort is very fast performing compared to others for arrays that have fairly random values.
Shell sort, merge sort, and tim sort are very good performing on average.
Ordered Insertion is great for adding some object to an array (Though that's not sorting). Although, an add on is the insertion sort.
Selection sort IMO is the easiest one to code. It's okay on average performance, usually not the best option though.
Bubble sort is one of the slowest average performing sorting algorithms. Likely only ever fast if the array is already nearly sorted. But even then, insertion sort may be the better option.
Take a look at some algorithms here:
https://www.toptal.com/developers/sorting-algorithms/
This can also show you when it's better to use one over the other.
+ 8
✓✓easy way
✓✓with iteration counter
✓✓running time of algorithms
✓✓please check this once
https://code.sololearn.com/cY7SC8lmidwy/?ref=app
+ 6
Wow thanks!
+ 2
Ohhhh I meant the ascending order, not bubble sort.
I know the algorithm with the 2 pointers, one for the current and the other for the +1 current and the rest of the array.
0
quick sort is best algorithm and it has minimum time complexity O(nlogn).