Main distinctive feature of this algorithm is that instead of comparing elements we divide each element to sequence of fields. Before sorting it is necessary to know two parameters: k and m, where k is quantity of digits in the longest key, and m is quantity of possible field values. In the presented vizualizer key length is four digits and, and m equals ten, because sorting is performed on decimal numbers. Let's say that elements of array A (displayed at the top row of visualizer) are k-digit decimal numbers. d(j,n) is j-th digit of number n from the right, B (displayed at the bottom row of visualizer) is additional array, that is empty in the beginning, and counter (displayed at the middle row of visualizer) is array of counters of size m, filled with zeros. For every j = 1, 2,..., k we should do the following steps: | |
1. Iterate over array A, increasing value of counter with index d(j,n) at every step. |
Copyright 2003 by Anton Ponomarev