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
3 Respuestas
+ 1
Thank you for your support ~ swim ~ .. ☺️