Created
November 28, 2011 01:30
-
-
Save renatoargh/1398706 to your computer and use it in GitHub Desktop.
MergeSort-Merge
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
public List<Int32> Merge(List<Int32> a, List<Int32> b) | |
{ | |
Int32 size = a.Count + b.Count; | |
List<Int32> mergedList = new List<Int32>(size); | |
a.Add(Int32.MaxValue); | |
b.Add(Int32.MaxValue); | |
Int32 i = 0; | |
Int32 j = 0; | |
while (i + j < size) | |
mergedList.Add(a[i] < b[j] ? a[i++] : b[j++]); | |
return mergedList; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment