Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
38 lines (30 loc) · 824 Bytes

File metadata and controls

38 lines (30 loc) · 824 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
38
# quick sorting of list input by user
def quickSort(list4,start,end):
if start>=end:
return
pivot = end-1
pivot = changePivot(list4,start,pivot)
quickSort(list4,start,pivot)
quickSort(list4,pivot+1,end)
return list4
# function to change the pivot
def changePivot(list4, start, pivot):
j=start
for i in range(start,pivot):
if list4[i]<list4[pivot]:
swap(list4,i,j)
j=j+1
swap(list4,j,pivot)
return j
# swaping of two elements
def swap(list2,i,j):
temp = list2[i]
list2[i]=list2[j]
list2[j]=temp
# input by user
n = int(input("Enter number of elemenys in list\n"))
list1=[]
for i in range(n):
elem = int(input())
list1.append(elem)
print("List after quick sorting: ",quickSort(list1,0,len(list1))) # function call
Morty Proxy This is a proxified and sanitized view of the page, visit original site.