which sorting method works fastest:
2.nearly sorted array
4.array with duplicates
*(assume that it is a large array with like 100,000 numbers)
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
no, i think u misunderstood my question. basically i need to do it 4 diff ways and seee hich one is the best for diff methods
these are my answers:
ranomized:best is: mergesort
Not the answer you are looking for? Search for more explanations.
if my choices are correct/make sense/
like for a randomized array, it is sorted fastest using mergesort
reverse is fastest with bubble...
isnt reverse better with insertion sort?
oh, ya, but thats not one of my choices.. i have buble sort,mege, selection
use merge here because bubble sort will take more steps
Of your choices, merge sort is by far the best.
Quicksort is probably the other major alternative to have a look at.
A cool one for arrays with only a small range of possible numbers is counting sort:
Merge sort and Randomised Quicksort have running times of O(n lg n).
Bubble sort and Selection sort is O(n^2)
Now O(n lg n) is faster than O( n^2), for a large enough n.
Hence, Merge sort and Quicksort beats Bubble and Selection sort.
Also, Counting sort has linear running time O(n). So, that's even better that O(n lg n), but it's complex and a little hard to understand.
the url above tells me
randomized -> merge sort
revese -> shell sort
nearly sorted->insertion sort
duplicates -> quick sort, but insertion works quite good as well.