Algorithm for sorting an array using another array named gaps[] -


this piece of code program. code tends sort array horses size n. how array gap in sorting array horses?

int gaps[]={701,301,132,57,23,10,4,1}; (k = 0; k < 8; k++) (i = gaps[k]; < n; ++i)  { temp = horses[i]; (j = i; j >= gaps[k] && horses[j-gaps[k]] > temp; j -= gaps[k]) horses[j] = horses[j-gaps[k]]; horses[j] = temp; } 

gaps[] experimentally derived sequence shell sort. take @ last entry in wiki table shell sort:

https://en.wikipedia.org/wiki/shellsort#gap_sequences

wiki reference sequence:

https://oeis.org/a102549


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -