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:
Comments
Post a Comment