I am currently studying sorting algorithms and have found a Merge Insertion Sort. I could hardly find anything for this, but only a few articles and links to books. Thus, this algorithm was discovered by Lester Ford Jr. and Selmer Johnson. This is partly described here: http://www2.warwick.ac.uk/fac/sci/dcs/teaching/material/cs341/FJ.pdf
My problem right now is understanding how the part of the insert works, and besides, what sequence of numbers 1, 3, 5, 11 is mentioned in the explanation of how to insert. It looks so familiar, but I just can't remember what it was.
What I currently have in the code is as follows:
void sort(void *data, size_t n, size_t s, int (*fcomp)(void*, void*))
{
if(!data) return;
if(n < 2 || s == 0) return;
size_t i = 0, j = 0, k = 0, l = 0, r = 0, m = 0;
void *be = malloc((n/2)*s);
void *le = malloc((n/2 + n%2)*s);
void *mc = malloc(n*s);
for(i = 0; i < n; i+=2)
{
if(fcomp(voidAdd(data, s, i), voidAdd(data, s, i+1)) >= 0)
{
memcpy(voidAdd(be, s, k++), voidAdd(data, s, i), s);
memcpy(voidAdd(le, s, j++), voidAdd(data, s, i+1), s);
}
else
{
memcpy(voidAdd(be, s, k++), voidAdd(data, s, i+1), s);
memcpy(voidAdd(le, s, j++), voidAdd(data, s, i), s);
}
}
sort(be, n/2, s, fcomp);
memcpy(mc, le, s);
memcpy(voidAdd(mc, s, 1), be, (n/2)*s);
j = n/2 + 1;
for(i = 1; i < n/2; i++)
{
k = ...;
}
memcpy(data, mc, n*s);
free(mc);
free(be);
free(le);
}
, pdf, b_3, b_2, b_5, b_4... , , .