Created
January 12, 2012 02:05
-
-
Save zallarak/1598089 to your computer and use it in GitHub Desktop.
Merge sort part 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def Merge(left, right): | |
output = [] | |
x, y = 0, 0 | |
while x < len(left) and y < len(right): | |
if left[x] <= right[y]: | |
output.append(left[x]) | |
x += 1 | |
else: | |
output.append(right[y]) | |
y += 1 | |
output += left[x:] | |
output += right[y:] | |
return output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment