Sorting algorithms/Cocktail sort with shifting bounds: Difference between revisions

m
added whitespace.
m (added whitespace.)
m (added whitespace.)
Line 26:
 
 
The improvement is basically that values "bubble" both directions through the array,
array,   because on each iteration the cocktail sort   ''bubble sorts''   once
forwards and once backwards.
 
After   ''ii''   passes,   the first   ''ii''   and the
last   ''ii''   elements in the array are in their correct
positions,   and don't to be checked (again).