Sorting | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Sorting

So I just had an idea for a "naive and inefficient" sorting algorithm, that is comparatively simple. The idea is to find the minimum in a list, then to find the next minimum without the previous minimum, then keep doing that until there are no more elements. Then the list is sorted. You would find the minimum by comparing and updating the value of the minimum based on the values in the list. Is there a name for this sorting algorithm? Sorry if this is cringy, but any responses/insights are welcome.

4th Apr 2021, 3:48 AM
Edward Finkelstein
Edward Finkelstein - avatar
6 Answers
+ 2
This is called Selection Sort .
4th Apr 2021, 4:03 AM
Hima
Hima - avatar
+ 4
Edward Finkelstein I believe this would be something like minimal length sorting algorithm.
4th Apr 2021, 4:12 AM
BroFar
BroFar - avatar
+ 4
Edward Finkelstein a simple example of a minimal length sorting algorithm https://code.sololearn.com/c5Y48sU0547Q/?ref=app
4th Apr 2021, 4:34 AM
BroFar
BroFar - avatar
+ 2
Hima, Ah ok, yes I see it is indeed a thing. And to think I felt so special for thinking of it all on my own lol! But it seems like it is actually a viable option in some cases...
4th Apr 2021, 4:07 AM
Edward Finkelstein
Edward Finkelstein - avatar
+ 1
Hima, I meant that it is more suited for some cases than for others, not that it doesn't work. It is apparently not as efficient as other algorithms, but it has the advantage of not performing swaps...
4th Apr 2021, 4:16 AM
Edward Finkelstein
Edward Finkelstein - avatar
0
Edward Finkelstein why only for some cases ? It will always work .
4th Apr 2021, 4:15 AM
Hima
Hima - avatar