we are now in position to describe the algorithm in the form of procedure called selectwhich is activated each time run has been copied and new source is selected for the next run we assume the existence of variable denoting the index of the current destination sequence ai and di denote the ideal and dummy distribution numbers for sequence jlevelintegeradarray of integerthese variables are initialized with the following valuesai di an- dn- level for - dummy note that select is to compute the next row of table the values (lan- (leach time that the level is increased the next goali the differences di ai(lai( - are also computed at that time the indicated algorithm relies on the fact that the resulting di decrease with increasing index (descending stair in fig note that the exception is the transition from level to level this algorithm must therefore be used starting at level select ends by decrementing dj by this operation stands for the replacement of dummy run on sequence by an actual run procedure selectvar izintegerbegin if [jd[ + then inc(jelse if [ then inc(level) : [ ]for : to - do [ : [ + [ ] [ : [ + end endj : enddec( [ ]end select assuming the availability of routine to copy run from the source src with rider onto fj with rider rjwe can formulate the initial distribution phase as follows (assuming that the source contains at least one run)repeat selectcopyrun until eof herehoweverwe must pause for moment to recall the effect encountered in distributing runs in the previously discussed natural merge algorithmthe fact that two runs consecutively arriving at the same destination may merge into single runcauses the assumed numbers of runs to be incorrect by devising the sort algorithm such that its correctness does not depend on the number of runsthis side effect can safely be ignored in the polyphase sorthoweverwe are particularly concerned about keeping track of the exact number of runs on each file consequentlywe cannot afford to overlook the effect of such coincidental merge an additional complication of the distribution algorithm therefore cannot be avoided it