Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
QuickSort
#python 3.6.9 def quick_sort(arr): def sort(low, high): if high <= low: return mid = partition(low, high) sort(low, mid - 1) sort(mid, high) def partition(low, high): pivot = arr[(low + high) // 2] while low <= high: while arr[low] < pivot: low += 1 while arr[high] > pivot: high -= 1 if low <= high: arr[low], arr[high] = arr[high], arr[low] low, high = low + 1, high - 1 return low return sort(0, len(arr) - 1) arr = [3, 5, 1, 2, 9, 6, 4, 7, 5] print(arr) quick_sort(arr) print(arr)
run
|
edit
|
history
|
help
1
This is really cool! keep up the good work!
by du, 6 months ago
.
by nika_chaduneli, 6 months ago
Please
log in
to post a comment.
Idd or even
RANDOM NUMBER
Play
filtering python3
abracadabra
Atur cara mengira luas permukaan dan isipadu sebuah trapezium
H.W5
Q3
library
Atur cara mengira luas dan isipadu sebuah trapezium
This is really cool! keep up the good work!
by du, 6 months ago.
by nika_chaduneli, 6 months agoPlease log in to post a comment.