Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Sun Dec 2 23:09:58 2018
- @author: micha
- """
- A=[]
- from random import randint
- for i in range(0,100):
- A.append(randint(1,100))
- print(A)
- print()
- def QuickSort(A,p,k):
- if(p<k):
- r = Partition(A,p,k)
- QuickSort(A,p,r-1)
- QuickSort(A,r+1,k)
- def Partition(A,p,k):
- x=A[k]
- i=p-1
- for j in range(p,k):
- if(A[j]<=x):
- i+=1
- A[i],A[j] = A[j],A[i]
- A[i+1],A[k] = A[k],A[i+1]
- return i+1
- QuickSort(A,0,len(A)-1)
- print(A)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement