Advertisement
arturParchem

[P]Quicsort 1 tablica

Oct 3rd, 2022
611
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. t = [9,8,7,6,5,5,4,3,2,1]
  2. def QuicSort(A,pocz,kon):
  3.     if pocz==kon:
  4.         return 0
  5.     piv= A[pocz]
  6.     L=pocz
  7.     P=kon
  8.     while L<=P:
  9.         while A[L]<piv:
  10.             L=L+1
  11.         while A[P]>piv:
  12.             P=P-1
  13.         if L<=P:
  14.             A[L],A[P]=A[P],A[L]
  15.             L=L+1
  16.             P=P-1
  17.     if P>pocz:
  18.         QuicSort(A,pocz,P)
  19.     if L<kon:
  20.         QuicSort(A,L,kon)
  21. print(QuicSort(t,0,len(t)-1))
  22. print(t)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement