mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
Update merge_sort_fastest.py
This commit is contained in:
parent
7f4b240d1a
commit
71fd719ab7
@ -7,15 +7,13 @@ Worst Case Scenario : O(n)
|
|||||||
def merge_sort(LIST):
|
def merge_sort(LIST):
|
||||||
start = []
|
start = []
|
||||||
end = []
|
end = []
|
||||||
while LIST:
|
while len(LIST) > 1:
|
||||||
a = min(LIST)
|
a = min(LIST)
|
||||||
b = max(LIST)
|
b = max(LIST)
|
||||||
start.append(a)
|
start.append(a)
|
||||||
end.append(b)
|
end.append(b)
|
||||||
try:
|
LIST.remove(a)
|
||||||
LIST.remove(a)
|
LIST.remove(b)
|
||||||
LIST.remove(b)
|
if LIST: start.append(LIST[0])
|
||||||
except ValueError:
|
|
||||||
continue
|
|
||||||
end.reverse()
|
end.reverse()
|
||||||
return (start + end)
|
return (start + end)
|
||||||
|
Loading…
Reference in New Issue
Block a user