Use radix exchange sort to sort the table below. The parameters are on top of the call stack, denote the bit to sort on and the boundaries of the currently active area. The parameters of the initial radix_exchange_sort function call have been placed in the stack as a starting point.
In each recursive call to this sort, the user first has to perform a series of swaps (dragging by mouse) to partition the area. After this the user can select the left subarea (by clicking the the indices of the area bounds), a smaller bit to sort on (by clicking the bit in the bit table) and then call the radix_exchange_sort-function (by clicking the call button) to place these parameters in the call stack. This procedure is then applied recursively.
When we return from a function call(by clicking the return button) we made to the left subarea, a call for the right subarea is performed respectively. For further details, please consult the pseudo-code provided below.
Some additional problems.
radix_exchange_sort( array :Array, left :integer, right :integer, bit :integer) split = partition(array, left, right, bit) if (bit > 0) if area is bigger than 1 radix_exchange_sort(array, left, split-1, bit-1) if area is bigger than 1 radix_exchange_sort(array, split, right, bit-1) end if return from function
partition( array :Array, left :integer, right :integer, bit :integer) : integer while left != right while (array(left).bit == 0 && left < right ) left = left + 1 while (array(right).bit == 1 && left < right ) right = right - 1 swap array elements at left, right end while if array(right).bit == 0 right = right + 1 return right