+ 2

BUBBLE SORT: How can you stop the bubble sort when the list is already sorted?

sometimes unnecessary iterations take place because the list is already sorted https://code.sololearn.com/cgJ9ARRhG5hZ/?ref=app

26th Feb 2022, 5:04 AM
David Ortega
David Ortega - avatar
1 Odpowiedź
0
you can add a function checking if the list is sorted before sorting it, but in most cases it will be unsorted, so more work will be done and it's useless so no sensible way
30th Jul 2022, 8:35 PM
Patrick
Patrick - avatar