Of the following sorting algorithms, which has a running time that is LEAST dependent on the initial ordering of the input?
(a) Insertion Sort
(b) Quick Sort
(c) Merge Sort
(d) Selection Sort
(e) Shell Sort
Insertion sort is O(n) best case, O(n^2) worst case.
Quick sort is O(n lg n) best case, O(n^2) worst case.
Merge sort is O(n lg n) best case, O(n lg n) worst case.
Selection sort is O(n^2) best case, O(n^2) worst case.
Shell sort is at least as good as O(n^1.25) best case, O(n^1.5) worst case.
So best[merge] = worst[merge] and best[selection] = worst[selection]. Why aren't they equally good answers?


LinkBack URL
About LinkBacks







Reply With Quote

Bookmarks