Which of the following sort algorithms are guaranteed to be O(n \log n) even in the worst case?
-
+ Shell Sort
- Shell sort is between O(n) and O(n^2)
+ Incorrect! Shell sort is between O(n) and O(n^2)
-
+ Quick Sort
- Quick sort can be O(n \log n), but if the pivot points are not well chosen and the list is just so, it can be O(n^2).
+ Incorrect! Quick sort can be O(n \log n), but if the pivot points are not well chosen and the list is just so, it can be O(n^2).
-
+ Merge SortCorrect! Merge Sort is the only guaranteed O(n \log n) even in the worst case. The cost is that merge sort uses more memory.
-
+ Insertion Sort
- Insertion sort is O(n^2)
+ Incorrect! Insertion sort is O(n^2)
@@ -37,21 +37,21 @@
Which sort should you use for best efficiency If you need to sort through 100,000 random items in a list?
-
+ MergeCorrect!
-
+ Selection
- Selection sort is inefficient in large lists.
+ Incorrect! Selection sort is inefficient in large lists.
-
+ Bubble
- Bubble sort works best with mostly sorted lists.
+ Incorrect! Bubble sort works best with mostly sorted lists.
-
+ Insertion
- Insertion sort works best with either small or mostly sorted lists.
+ Incorrect! Insertion sort works best with either small or mostly sorted lists.