What is the significance of selection sort? It has a time complexity of O(n^2) even in best case scenario. So why is it still prevalent?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
- It is simple to write and intuitive for people to understand
- It is the closest to the way real humans approach sorting lists.
- It functions in-place in memory
- After n iterations you know the first n elements are sorted. After the first iteration the first item is sorted, after the second is finished the first 2 are sorted, etc...