mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
small change!
This commit is contained in:
parent
ca7eb46756
commit
31f968f589
@ -1,13 +1,11 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
def quick_sort_3partition(sorting, left, right):
|
def quick_sort_3partition(sorting, left, right):
|
||||||
|
|
||||||
if right <= left:
|
if right <= left:
|
||||||
return
|
return
|
||||||
a = left
|
a = i = left
|
||||||
b = right
|
b = right
|
||||||
pivot = sorting[left]
|
pivot = sorting[left]
|
||||||
i = left
|
|
||||||
while i <= b:
|
while i <= b:
|
||||||
if sorting[i] < pivot:
|
if sorting[i] < pivot:
|
||||||
sorting[a], sorting[i] = sorting[i], sorting[a]
|
sorting[a], sorting[i] = sorting[i], sorting[a]
|
||||||
@ -30,4 +28,4 @@ if __name__ == '__main__':
|
|||||||
user_input = raw_input('Enter numbers separated by a comma:\n').strip()
|
user_input = raw_input('Enter numbers separated by a comma:\n').strip()
|
||||||
unsorted = [ int(item) for item in user_input.split(',') ]
|
unsorted = [ int(item) for item in user_input.split(',') ]
|
||||||
quick_sort_3partition(unsorted,0,len(unsorted)-1)
|
quick_sort_3partition(unsorted,0,len(unsorted)-1)
|
||||||
print(unsorted)
|
print(unsorted)
|
||||||
|
Loading…
Reference in New Issue
Block a user