Skip to content

Instantly share code, notes, and snippets.

@renatoargh
Created November 28, 2011 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renatoargh/1398706 to your computer and use it in GitHub Desktop.
Save renatoargh/1398706 to your computer and use it in GitHub Desktop.
MergeSort-Merge
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