javascript-algorithms
javascript-algorithms copied to clipboard
Added Shaker Sort Algorithm
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)