Created
August 9, 2016 14:17
-
-
Save kishan3/c4d6625a1aa0dc62e6d980cf9f37e362 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# n = size of array1 | |
# m = size of array2 | |
def merge(array1, array2, n , m): | |
x = 0 | |
y = 0 | |
result = [] | |
k = 0 | |
while (x < n) and (y < m): | |
if array1[x] > array2[y]: | |
result.append(array1[x]) | |
x+=1 | |
else: | |
result.append(array2[y]) | |
y+=1 | |
while x < n: | |
result.append(array1[x]) | |
x+=1 | |
while y < m: | |
result.append(array2[y]) | |
y+=1 | |
for i in result: | |
print (i, end=" ") | |
print("") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment