FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
basic-programs/python/recursion/quicksort.py at master · ProjectRipo/basic-programs · GitHub
ProjectRipo
/
basic-programs
Public
forked from
utkarsh-shekhar/basic-programs
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
basic-programs
/
python
/
recursion
/
quicksort.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
46 lines (30 loc) · 1.01 KB
Breadcrumbs
basic-programs
/
python
/
recursion
/
quicksort.py
Copy path
File metadata and controls
46 lines (30 loc) · 1.01 KB
Raw
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
39
40
41
42
43
44
45
46
from
random
import
randint
def
_quicksort
(
arr
,
lo
,
hi
):
if
lo
<
hi
:
p
=
partition
(
arr
,
lo
,
hi
)
_quicksort
(
arr
,
lo
,
p
-
1
)
_quicksort
(
arr
,
p
+
1
,
hi
)
def
partition
(
arr
,
lo
,
hi
):
#pivot is chosen as first element of list
#shuffle pivot ie first element with any other element randomly
randidx
=
randint
(
lo
,
hi
)
arr
[
randidx
],
arr
[
lo
]
=
arr
[
lo
],
arr
[
randidx
]
pivot
=
arr
[
lo
]
left
,
right
=
lo
,
hi
while
True
:
while
arr
[
left
]
<=
pivot
:
left
+=
1
if
left
==
hi
:
break
while
arr
[
right
]
>
pivot
:
right
-=
1
if
right
==
lo
:
break
if
(
left
>=
right
):
break
arr
[
left
],
arr
[
right
]
=
arr
[
right
],
arr
[
left
]
arr
[
lo
],
arr
[
right
]
=
arr
[
right
],
arr
[
lo
]
return
right
def
quicksort
(
arr
):
if
type
(
arr
)
is
list
:
_quicksort
(
arr
,
0
,
len
(
arr
)
-
1
)
Back
|
FazBrowse Home
|
New Git URL