Question: The figure below explains what a stable sorting algorithm is. To be able to be categorized as a stable sorting algorithm, the orders of the

 The figure below explains what a stable sorting algorithm is. To

The figure below explains what a stable sorting algorithm is. To be able to be categorized as a stable sorting algorithm, the orders of the elements in the output must follow the same order the elements had in the input. So if there are 2 numbers with the same value on the input, their order must be preserved in the output. Based on this definition, why Mergesort is a stable sorting algorithm? It is stable since each half preserve the original input order and order is preserved during the combine step. Assessment is wrong, Mergesort is not a stable sorting algorithm. It is not stable since you can't control the pivot position and how the algorithm will partition the input. It is not stable since depending on the inputs it can take O(nlogn) or O(n2)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!