Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import random
  2. import time
  3. lista10000=[]
  4. for i in range (1, 10000001):
  5. lista10000.append(i)
  6.  
  7. def bubbleSort(lista):
  8. inicio = time.clock()
  9. ordenado = False
  10. while ordenado==False:
  11. print(lista)
  12. ordenado = True
  13. for i in range (1, len(lista)):
  14. if (lista[i]<lista[i-1]):
  15. temp = lista[i]
  16. lista[i] = lista[i-1]
  17. lista[i-1] = temp
  18. ordenado=False
  19. print("Bubble sort levou ",format(time.clock()-inicio, ".2f"), "segundos para 10.000 elementos.")
  20. bubbleSort(lista10000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement