Cocktail Sort
Cocktail Sort
~ Comparison Sort
Cocktail Sort uses the method of comparing adjacent datas and then
swapping, hence comparison / exchange sort
Bubble Sort
Cocktail Shaker
Sort
Implementation
procedure cocktail_sort(a[], n) // a[] = list of sortable items & n =
number of elements
{
flag=true;
do{
flag=false
for each i=n-1 to 0, do : // Left to Right
if a[i-1] > a[i]
//swap both & flag=true