Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

how to implement merge sort using memmove in c

void insertion_sort(int* arr, int len)
{
	int i, j, si, swp;
	for(i = 0; i < len - 1; i++)
	{
		si = i;
		for(j = i + 1; j < len; j++)
		{
			if(arr[j] < arr[si])
				si = j;
		}
		if(si != i)
		{
			swp = arr[si];
			memmove(&arr[i + 1], &arr[i], (si - i) * sizeof(int));
			arr[i] = swp;
		}
	}
}
Source by blog.fourthwoods.com #
 
PREVIOUS NEXT
Tagged: #implement #merge #sort #memmove
ADD COMMENT
Topic
Name
6+3 =