Quiz Mergesort - Stability
Here are three descriptions of stable algorithms. One of the descriptions is false. Which one is it? -They preserve the relative order of items with equal keys. -They ensures that all elements are in ascending order. -They ensure that if an array has been sorted by a given key and then we sort it by a second field it maintains the original sort for all elements that have equal keys in that second field.
They ensures that all elements are in ascending order.
Check all algorithms that are stable -Mergesort -Selection Sort -Insertion Sort
- Mergesort - Insertion Sort
Mergesort is a stable sorting algorithm as long as the merge method is implemented correctly. Which of the following should you do if you want to ensure that your implementation of the merge method results in a stable mergesort? -If 2 keys are equal it takes the element from the right subarray -If 2 keys are equal it takes the element from the left subarray -If 2 keys are equal it takes the element from the subarray that was accessed last.
If 2 keys are equal it takes the element from the left subarray
A sorting algorithm is stable if equal items are never moved past each other
True