FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
All-Algorithms-In-Python/algorithms/sorting/quick_sort.py at master · codeme254/All-Algorithms-In-Python · GitHub
codeme254
/
All-Algorithms-In-Python
Public
forked from
AllAlgorithms/python
Notifications
You must be signed in to change notification settings
Fork
1
Star
2
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
All-Algorithms-In-Python
/
algorithms
/
sorting
/
quick_sort.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
14 lines (13 loc) · 484 Bytes
Breadcrumbs
All-Algorithms-In-Python
/
algorithms
/
sorting
/
quick_sort.py
Copy path
File metadata and controls
14 lines (13 loc) · 484 Bytes
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
"""
Here is the implementation of quicksort algorithm in python by Pramod Bharti
quick_sort() function takes an unsorted array and prints sorted array
"""
def
quick_sort
(
arr
):
if
len
(
arr
)
<=
1
:
return
arr
pivot
=
arr
[
len
(
arr
)
//
2
]
left
=
[
x
for
x
in
arr
if
x
<
pivot
]
middle
=
[
x
for
x
in
arr
if
x
==
pivot
]
right
=
[
x
for
x
in
arr
if
x
>
pivot
]
return
quick_sort
(
left
)
+
middle
+
quick_sort
(
right
)
print
(
quick_sort
([
5
,
2
,
8
,
3
,
9
,
12
,
43
]))
# This will print [2,3,5,8,9,12,43]
Back
|
FazBrowse Home
|
New Git URL