选择排序:一种简单的比较排序算法。它反复在未排序部分中选择最小(或最大)元素,并把它放到序列的前端(或后端),直到全部有序。时间复杂度通常为 **O(n²)**,额外空间复杂度为 O(1)(原地排序),但一般不稳定(相等元素的相对顺序可能改变)。
/səˈlɛkʃən sɔːrt/
Selection sort finds the smallest item and moves it to the front.
选择排序会找到最小的元素并把它移到最前面。
Although selection sort is easy to implement, it performs poorly on large datasets compared with faster algorithms like quicksort or mergesort.
尽管选择排序很容易实现,但与快速排序或归并排序等更快的算法相比,它在大规模数据上表现较差。
“selection”来自拉丁语 selectio(挑选、选择),强调“从一组中选出某个元素”;“sort”源自法语 sortir 相关词义演变,现代英语中表示“分类、排序”。合起来 selection sort 字面意思就是“通过不断选择元素来完成排序”。