0

please find bug in bubble sort algo

elem = [11,23,8,14,30,9,6,17,22,28,25,15,7,10,19] def bubble_sort(lst): for e in range(len(lst)): swap = -1 i = 0 while i < len(lst)-1: swap = 0 if lst[i] > lst[i+1]: lst[i], lst[i+1] = lst[i+1], lst[i] swap+=1 i+=1 if swap == 0: break print(lst) bubble_sort(elem) #Code is not sorting properly

21st Apr 2019, 1:08 PM
Aakash Gupta
Aakash Gupta - avatar
1 Resposta
+ 1
Thank you for your support ~ swim ~ .. ☺️
22nd Apr 2019, 4:57 AM
Aakash Gupta
Aakash Gupta - avatar