Merge Sort Flashcards
Merge sort is a stable sorting algorithm, which means it maintains the ___________________ in the input array
relative order of equal elements
What is the BEST case time complexity of Merge Sort, and when does it occur?
O(n log n), When the array is already sorted or nearly sorted.
What is the AVERAGE case time complexity of Merge Sort, and when does it occur?
O(n log n), When the array is randomly ordered.
What is the WORST case time complexity of Merge Sort, and when does it occur?
O(n log n), When the array is sorted in reverse order.
Why is merge sort suitable for parallel processing?
It independently merges subarrays
Merge sort is not an in-place sorting algorithm. What is the disadvantage of this?
It requires additional memory to store the sorted data.
Which is faster: merge sort or quick sort? Why?
Merge Sort is Slower than QuickSort in general as QuickSort is more cache friendly because it works in-place.
What sort of data structure is merge sort especially good at sorting?
Linked lists
______.sort in Java uses QuickSort while ______.sort uses MergeSort.
Arrays.sort; Collections.sort