请输入您要查询的字词:

 

单词 StableSortingAlgorithm
释义

stable sorting algorithm


A stable sorting algorithm is any sorting algorithm that preserves the relative ordering of items with equal values. For instance, consider a list of ordered pairsMathworldPlanetmath

L:={(A,3),(B,5),(C,2),(D,5),(E,4)}.

If a stable sorting algorithm sorts L on the second value in each pair using the relationMathworldPlanetmath, then the result is guaranteed to be{(C,2),(A,3),(E,4),(B,5),(D,5)}. However, if an algorithmMathworldPlanetmath is not stable, then it is possible that (D,5) may come before (B,5) in the sorted output.

Some examples of stable sorting algorithms are bubblesort and mergesort (although the stability of mergesort is dependent upon how it is implemented). Some examples of unstable sorting algorithms are heapsortMathworldPlanetmath and quicksortMathworldPlanetmath (quicksort could be made stable, but then it wouldn’t be quick any more).Stability is a useful property when the total ordering relation is dependent upon initial position. Using a stable sorting algorithm means that sorting by ascending position for equal keys is built-in, and need not be implemented explicitly in the comparison operator.

随便看

 

数学辞典收录了18232条数学词条,基本涵盖了常用数学知识及数学英语单词词组的翻译及用法,是数学学习的有利工具。

 

Copyright © 2000-2023 Newdu.com.com All Rights Reserved
更新时间:2025/5/4 9:35:51