-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP1.py
More file actions
37 lines (33 loc) · 741 Bytes
/
P1.py
File metadata and controls
37 lines (33 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import pandas as pd
from random import *
array=[]
def randomArr():
for i in range(0,50000):
arrValues=randint(0,50000)
array.append(arrValues)
randomArr()
print(array)
def Partition(Arr,p,r):
x=Arr[r-1]
# print(x)
i=p-1
# print(i)
for j in range(p,r-1):
if x <= Arr[j]:
i=i+1
# print(i)
temp=Arr[i]
Arr[i]=Arr[j]
Arr[i]=temp
temper=Arr[i+1]
Arr[i+1]=Arr[x]
Arr[x]=temper
return i+1
def QuickSort(Arr,p,r):
if p<r:
q=Partition(Arr,p,r)
QuickSort(Arr,p,q-1)
QuickSort(Arr,q+1,r)
print(Arr)
return Arr
print(QuickSort(array,1,len(array)))