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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -