Bi-Directional Bubble Sort :
Bi-Directional Bubble Sort The bi-directional bubble sort compares each adjacent pair of elements in an array. The values will be swap if necessary.
The values passes from the beginning to the end and also from the end to the beginning.
It stops when there is no any element to swap.
Bi-directional bubble sorting also known as cocktail shaker sort, shaker sort, double-direction bubble sort.
The complexity of bi-directional bubble sort is O(n2).
Bi-Directional Bubble Sort :
Bi-Directional Bubble Sort Bi-directional bubble sort is better than bubble sort.
In Bi-directional bubble sort at least one elements is moved forward or backward to its place in the array with each pass.
But in the case of bubble sort moves elements by forward direction to its place, but can only move elements backward in only one location in each pass.