Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. import numpy as np
  2.  
  3. def BUBBLE_SORT(A):
  4. n = np.size(A)
  5. m = n-1
  6. while m > 1:
  7. k = 0
  8. while k < m :
  9. if A[k] > A[k+1]:
  10. A[k],A[k+1] = A[k+1],A[k]
  11. k += 1
  12. m -= 1
  13. return A
  14.  
  15. def QUICK_SORT(A,L,R):
  16. if L < R:
  17. p = L
  18. k = L+1
  19. while k <= R:
  20. if A[k] < A[L]:
  21. A[p+1], A[k] = A[k], A[p+1]
  22. p += 1
  23. k += 1
  24. A[L], A[p] = A[p], A[L]
  25. A = QUICK_SORT(A,L,p-1)
  26. A = QUICK_SORT(A,p+1,R)
  27. return A
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement