当前位置:网站首页>Simple selection sort of selection sort

Simple selection sort of selection sort

2022-07-05 06:16:00 Beauty of algorithm and programming

1. introduction

As soon as I hear the words of selective sorting, my first reaction is to sort through selection , So is our first reaction right , Let's verify , Understand its definition . Simple selection sort : The simplest selection method is to scan the elements in the sequence sequentially , Remember the smallest element encountered ( At the end of a scan, the smallest element is found . Repeated scanning can complete the sorting work ). Obviously, that's what we understand , Each time, select the smallest element of the sequence and sort it in turn .

2. problem

Given a sequence , How do we sort it by simple selection sorting , The following will be described one by one .

Example 1:27,54,18,36,78,48

Output :18,27,36,48,54,78

3. Algorithm description

Example 1 It's an out of order sequence , What we need to do is to arrange the disordered sequence into a sequence from small to large . This problem is realized by simple selection sorting , According to the definition of simple sorting , The first is to find the smallest in the sequence , Then find the second smallest ( That is, in addition to the last found element , Find the smallest... From the remaining elements ), Repeat the search until the sorting is complete , This process is illustrated below .

21699cbf3923e2145a61f7e84a283c0a.png

4. Conclusion

The method is a simple exchange using a direct selection sorting algorithm , That is, the above position of exchanging two elements . This is my understanding of simple selection sorting , There may be a better understanding , I will continue to study .

Internship editor : Heng Hui

Source of contribution : Deep learning and cultural tourism application laboratory (DLETA)

原网站

版权声明
本文为[Beauty of algorithm and programming]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140619034322.html