mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-22 01:02:04 +00:00
Update merge_sort_fastest.py
I have modified the code a little to make it work as expected!
This commit is contained in:
parent
237df47a31
commit
7f4b240d1a
|
@ -7,14 +7,15 @@ Worst Case Scenario : O(n)
|
||||||
def merge_sort(LIST):
|
def merge_sort(LIST):
|
||||||
start = []
|
start = []
|
||||||
end = []
|
end = []
|
||||||
a = LIST[0]
|
while LIST:
|
||||||
b = LIST[-1]
|
|
||||||
while (LIST.index(a) == LIST.index(b) and len(LIST) <=2):
|
|
||||||
a = min(LIST)
|
a = min(LIST)
|
||||||
b = max(LIST)
|
b = max(LIST)
|
||||||
start.append(a)
|
start.append(a)
|
||||||
end.append(b)
|
end.append(b)
|
||||||
LIST.remove(a)
|
try:
|
||||||
LIST.remove(b)
|
LIST.remove(a)
|
||||||
|
LIST.remove(b)
|
||||||
|
except ValueError:
|
||||||
|
continue
|
||||||
end.reverse()
|
end.reverse()
|
||||||
return start + end
|
return (start + end)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user