javascript-algorithms icon indicating copy to clipboard operation
javascript-algorithms copied to clipboard

Added Shaker Sort Algorithm

Open Pixelrick420 opened this issue 2 months ago • 0 comments

This pull request adds the Shaker Sort (also known as Cocktail Shaker Sort or Bidirectional Bubble Sort) algorithm to the repository.

Implemented the Shaker Sort algorithm in javascript-algorithms/src/sorting/shakersort.js Included a brief description and time complexity analysis in the file’s docstring.

Shaker Sort is a variation of Bubble Sort that sorts bidirectionally : it passes through the list in both directions alternately.

Best Case: O(n) (already sorted) Average Case: O(n²) Worst Case: O(n²)

Space Complexity: O(1) (in-place)

Pixelrick420 avatar Oct 19 '25 20:10 Pixelrick420