Advertisement
davegimo

BubbleSort

Nov 8th, 2020
781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. lista = [10,5,1,4,2,16,6]
  2.  
  3. def bubblesort(l):
  4. n = len(l)
  5.  
  6. for i in range(n-1):
  7. print(l)
  8. for j in range(n-i-1):
  9. if l[j] > l[j+1]:
  10. temp = l[j+1]
  11. l[j+1] = l[j]
  12. l[j] = temp
  13.  
  14.  
  15. bubblesort(lista)
  16. print(lista)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement