Algorithms and Data Structures [30 Days] Training Camp - Principles and Code Explanation of Simple Selection Sort, Tree Selection Sort, Heap Sort (24)

simple selection sort

In a set of numbers to be sorted, select the smallest (or largest) number and exchange it with the number in the first position; then find the smallest (or largest) number and the number in the second position in the remaining numbers Swap, and so on, until the n-1th element (the penultimate number) is compared with the nth element (the last number).

If you read the animation below carefully, you should understand


Traverse the sequence, scanning the sequence backwards at the current position each time, note the position of the minimum value, and then swap the minimum value with the value at the current position

insert image description here

Simple selection sort algorithm features

time complexity:

Guess you like

Origin blog.csdn.net/weixin_47723732/article/details/127476365