Update merge_sort_fastest.py

I have modified the code a little to make it work as expected!
This commit is contained in:
Harshil 2018-05-21 10:21:33 +02:00 committed by GitHub
parent 237df47a31
commit 7f4b240d1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,14 +7,15 @@ Worst Case Scenario : O(n)
def merge_sort(LIST):
start = []
end = []
a = LIST[0]
b = LIST[-1]
while (LIST.index(a) == LIST.index(b) and len(LIST) <=2):
while LIST:
a = min(LIST)
b = max(LIST)
start.append(a)
end.append(b)
LIST.remove(a)
LIST.remove(b)
try:
LIST.remove(a)
LIST.remove(b)
except ValueError:
continue
end.reverse()
return start + end
return (start + end)