previous | start | next

Insert the Elements

Copy the values from the array a to an auxilliary array, aux, at the index indicated by the count array and update that index for the digit position for this pass.

                       old    updated
      a               count   count           aux
 0   412           0    0       0          0   
 1   012           1    1       1         1   
 2   101           2    2       3   2   
 3   432           3    4       7         3   412
 4   302           4    0       7         4   
 5   201           5    0       7         5   
 6   410           6    0       7         6   
                   .    .       .
                   .    .       .
                   9    0       7
   

412 is copied to the position indicated by count[2], which is position 3.

count[2] should now be incremented to 4, to be ready for the next element whose digit is 2.



previous | start | next