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 linear_merge(list1, list2): | |
list1.sort (list1.extend (list2)) | |
return list1 |
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 linear_merge(list1, list2): | |
result = [] | |
while len(list1) and len(list2): | |
if list1[0] < list2[0]: | |
result.append(list1.pop(0)) | |
else: | |
result.append(list2.pop(0)) | |
result.extend(list1) | |
result.extend(list2) |
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 linear_merge(list1, list2): | |
list1.sort (list1.extend (list2)) | |
return list1 |
NewerOlder