1. Description
This example is similar to the previous one-dimensional bubble sort, except that the numbers are stored in two-dimensional arrays instead of one-dimensional arrays.
This 2D bubble sort is an extension of the 1D bubble sort. In this 2D version, elements are compared for vertical as well as for horizontal neighbors. Again, swaps are made between two neighbors, if necessary. Smaller numbers will migrate to the upper-left corner of the cellular space while larger numbers move towards the lower-right corner. The simulation results are shown in the above animated figure.
2. Download
next example
|