1. Description
This example implements a one-dimensional bubble sort algorithm using the Trend simulation environment.
In this bubble sort, no centralized control is used in sorting the elements of the array. In stead, each element sorts itself by comparing its value with the values of its neighbors. If one element notices its value is less than the value of its left neighbor, this element has to swap its value with this neighbor. Similarly, if its value is greater than the right neighbor, they have to swap their values as well. This approach will lead to a sorted array eventually.
(1-D bubble sort tutorial)
2. Download
next example
|