[Home]
[Contents]
[Chapter]
[Previous Algorithm]
[Next Algorithm]


Selection of next file for polyphase merge sort


nextfile() {extern int maxfiles, maxruns[], actruns[]; int i, j, inc; actruns[0]++; if (actruns[0]>maxruns[0]) { /*** Find next perfect distribution ***/ inc = maxruns[maxfiles]; maxruns[0] += (maxfiles-2) * inc; for (i=maxfiles; i>1; i--) maxruns[i] = maxruns[i-1] + inc; } j = 2; /*** select file farthest from perfect ***/ for (i=3; i<=maxfiles; i++) if ( maxruns[i]-actruns[i]> maxruns[j]-actruns[j] ) j = i; actruns[j]++; return( j ); };

C source (444.next.c)



© Addison-Wesley Publishing Co. Inc.