Skip to content

Commit

Permalink
Small mistake in sort/merge_sort.py array merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Alisha committed Apr 28, 2017
1 parent de89258 commit ba7b21e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions sort/merge_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 26,12 @@ def merge(left, right):
else:
arr.append(right[right_cursor])
right_cursor =1
# Add the left overs if there's any left to the result
if left:
arr.extend(left[left_cursor:])
if right:
arr.extend(right[right_cursor:])
return arr
# Add the left overs if there's any left to the result
for i in range(left_cursor,len(left)):
arr.append(left[i])
for i in range(right_cursor,len(right)):
arr.append(right[i])

array = [1,5, 7,4,3,2,1,9,0,10,43,64]
print(array)
print(merge_sort(array, 0, len(array)-1))
print(array)
print(merge_sort(array))

0 comments on commit ba7b21e

Please sign in to comment.