Figure 4. Illustration of Oyelami’s
sort.
Bidirectional Bubble Sort is now applied to (*) to sort the elements
that are adjacent as shown in Figure 4.
Since no swap has occurred, the algorithm stops, eliminating the
need to pass from the top back to the bottom. In all, 5 comparisons
were carried out and only 2 swaps. This shows that this algorithm
performs better than Batcher’s that has 5 comparisons and 4
swaps. When compared with Bitonic Sort (6 comparisons and 4
swaps) it performs better. The algorithm is presented below:
Oyelami’s Sort (array, size)
Begin
1. i = 1
2. j = size
3. while (i < j) do
begin
4. if array[i] > array[j] swap (array, i, j)
5. i = i + 1
6. j = j – 1
end
[Call Bidirectional Bubble Sort to sort the adjacent elements]
7. Bidirectional Bubble Sort (A, size:int)
End