Lowest price ever! Learn Generative AI for 48% less!
Get my discount
0

Name of a sorting algorithm

Down below in the link, there is a sorting algorithm. Please can anyone go through the codes and tell me if there is any similar algorithm like it in the current world, if yes then what is it's name? https://code.sololearn.com/cA13a3a10A42/?ref=app

8th Apr 2021, 7:37 PM
Md. Faheem Hossain
Md. Faheem Hossain - avatar
8 Answers
+ 3
Nice one! It's an interesting one for sure but I think in essence this is a variation on bubblesort. We can see that small elements are bubbling to the front of the list, but you also do this thing where you swap elements that are apart by 2 so occasionally one element stops bubbling and another one takes over. The best way to see what is happening is to have it sort a reversed list, the algo generally moves numbers towards the front one at a time just like bubblesort would. It's likely O(n²) like regular bubblesort aswell, but maybe a bit more efficient because you are partially sorting as you are bubbling. It's really neat to watch the algorithm work! You should do one of these videos where you let it sort 200 random numbers but visualized as a bar chart.
9th Apr 2021, 1:01 AM
Schindlabua
Schindlabua - avatar
+ 1
Ananiya Jemberu as far as I know, Python uses Tim Sort, but I wasn't talking about that; I asked whether the code matches with any of the sorting algorithms or not.
8th Apr 2021, 7:46 PM
Md. Faheem Hossain
Md. Faheem Hossain - avatar
+ 1
Oh ok Faheem I hope some one will help u out :P
8th Apr 2021, 7:48 PM
Ananiya Jemberu
Ananiya Jemberu - avatar
+ 1
Faheem That looks interesting. Great job writing your own sorting algorythm. To get an answer to something like this, you’ll probably have to post it on stackoverflow or other website for more advanced users. Maybe someone here will know. But either way, great job coming up with your algorythm on your own.
8th Apr 2021, 7:55 PM
Jerry Hobby
Jerry Hobby - avatar
+ 1
Jerry Hobby Thanks!
8th Apr 2021, 7:56 PM
Md. Faheem Hossain
Md. Faheem Hossain - avatar
0
Heres the official sort library https://docs.python.org/3/howto/sorting.html if you are interested on you can go through it
8th Apr 2021, 7:43 PM
Ananiya Jemberu
Ananiya Jemberu - avatar
0
Schindlabua Thanks!
23rd Apr 2021, 8:03 PM
Md. Faheem Hossain
Md. Faheem Hossain - avatar
0
Thanks to Coder Kitten for giving it the name, Crane Sort. If visualized, then this algorithm will look like Insertion Sort. Though key concepts are slidely different, but algorithmitically there is a lot of similarities between it & Gnome Sort. It is much slower than Insertion Sort; think like this, suppose a crane is moving throughout the array and sorting it. Now at index i if it gets an unsorted element, then it'll have to move back to find the place where the element will fit. After putting the element in the correct place, the crane will have to come all the way back to i again. Since it has no magical power, that it will disappear and again appear at i+1th index, so it'll unnecessarily keep checking the sorted part of the array upto i. This is the key difference between the Insertion Sort and the Crane Sort. Now you might ask, why don't we give it the magical power? The answer is simple. This is also an algorithmic idea, probably in this algorithm it is degrading the runtime, but who knows, oneday t
24th Apr 2021, 7:16 PM
Md. Faheem Hossain
Md. Faheem Hossain - avatar