Stability concept of sorting algorithm

Stability is a particularly important evaluation criterion. Stable algorithms do not change the relative order of the elements' positions in the process of sorting. Conversely, unstable sorting algorithms often change this order, which we do not want to see. When we use a sorting algorithm or select a sorting algorithm, we hope that the order will not change and be more stable, so the stability of the sorting algorithm is a particularly important parameter measurement index basis. Just like space complexity and time complexity, sometimes it is even more important than time complexity and space complexity. Therefore, it is often possible to evaluate the quality of a sorting algorithm from the following aspects:
(1) Time complexity: that is, the operation from the initial state of the sequence to the shift of the sorting algorithm changes to the final sorted result state A measure of the time spent in the process.
(2) Space complexity: it is the space cost from the initial state of the sequence to the final state through the process of sorting shift transformation.
(3) Usage scenarios: There are many sorting algorithms. Different sorting algorithms are suitable for different kinds of scenarios. Sometimes it may be necessary to save space and not so much time. On the contrary, sometimes it is to think about more time and space requirements. Not so high, in general, you will have to make a choice from a certain aspect.
(4) Stability: Stability is an issue that must be considered regardless of time and space, and is often a very important factor affecting selection.

Published 19 original articles · won 7 · views 573

Guess you like

Origin blog.csdn.net/liu201812/article/details/104761272