- What is Bogo Sort and What is Cocktail Shaker Sort
- How to implement these two sorting algorithms
- Time Complexity of these sorting algorithms
- More in-depth knowledge of some uncommon sorting algorithms

while not isInorder(deck);shuffle deck;

**.**

**.**

**.**

**.**

**The code for the BogoSort Algorithm is**

Worst Case: O(∞)(Since no upper bound is present)Time Complexity

Average Case: O(n*n!)

Best Case: O(n) (when an array is already sorted

**2. Cocktail Shaker Sort**

**Algorithm**

**Part 1:**In the first part, looping of the array starts from left, and it moves towards the right, just like in bubble sort. The value of adjacent items are compared during the looping if the value on the left is greater than the right one, then the swapping of the two occurs. After the iteration ends, the value at the end is the greatest one.

**Part 2:**The second part of the looping starts from the item just before the item, which is most recently sorted. This looping will continue in the opposite direction with all the comparisons of the adjacent items with necessary swapping where ever it is required.

**First Pass(Forward):**

(**6**** 2** 5 3 9 1 3) ? (**2**** 6** 5 3 9 1 3), since 6 > 2

(2 **6**** 5** 3 9 1 3) ? (2 **5**** 6** 3 9 1 3), since 6 > 5

(2 5 **6**** 3** 9 1 3) ? (2 5 **3**** 6** 9 1 3), since 6 > 3

(2 5 3 **6**** 9** 1 3) ? (2 5 3 **6**** 9** 1 3)

(2 5 3 6 **9**** 1** 3) ? (2 5 3 6 **1**** 9** 3), since 9 > 1

(2 5 3 6 1 **9**** 3**) ? (2 5 3 6 0 **3**** 9**), since 9 > 3

the greatest element is present at the last index

**First Pass (Backward):**

(2 5 3 6 **1**** 3** 9) ? (2 5 3 6 **1**** 3** 9)

(2 5 3 **6**** 1** 3 9) ? (2 5 3 **1**** 6 3** 9), since 6 > 1

(2 5 **3**** 1** 6 3 9) ? (2 5 **1**** 3** 6 3 9),since 3 > 1

(2 **5**** 1** 3 6 3 9) ? (2 **1**** 5** 3 6 3 9),since 5 > 1

(**2**** 1** 5 3 6 3 9) ? (**1**** 2** 5 3 6 3 9),since 2 > 1

the smallest element is present at the first index

**Second Pass(Forward):**

(1 **2**** 5** 3 6 3 9) ? (1 **2**** 5** 3 6 3 9)

(1 2 **5**** 3** 6 3 9) ? (1 2 **3**** 5** 6 3 9), since 5 > 3

(1 2 3 **5**** 6** 3 9) ? (1 2 3 5** 6** 3 9)

(1 2 3 5 **6**** 3** 9) ? (1 2 3 5 **3**** 6** 9), since 6 > 3

**Second Pass(****Backward****):**

(1 2 3 **5**** 3** 6 9) ? (1 2 3 **3**** 5** 6 9), since 5 > 3

(1 2 **3**** 3** 5 6 9) ? (1 2 **3**** 3** 5 6 9)

(1 **2**** 3** 3 5 6 9) ? (1 2** 3 3** 5 6 9)

**The code for the Cocktail sort is**

**Time Complexity**

**Worst and Average Case Time Complexity:**O(n*n).

**Best Case Time Complexity:** O(n). The best-case occurs when an array is already
sorted.

**Conclusion**

## 0 comments: