0

Bubble sort...or is it?

I made two sort algos, one (the first one) definitely is a bubble sort as it compares two adjacent elements with reduced range as it goes along...but the second one uses the outer loops range variable in the compare and swap routine. Both do the job, the second one is faster...but what type of sort is it (the second one)? https://code.sololearn.com/ceJ7trrQ9tnV/#py

13th Apr 2020, 9:13 PM
rodwynnejones
rodwynnejones - avatar
2 Respuestas
+ 3
It is Selection Sort. https://www.sololearn.com/learn/703/ The difference is that your algorithm takes the maximum element during each iteration.
14th Apr 2020, 1:02 AM
Diego
Diego - avatar
+ 1
Thank you for your reply.
14th Apr 2020, 9:25 PM
rodwynnejones
rodwynnejones - avatar