Stooge Sort is a recursive sorting algorithm. It is not much efficient but interesting sorting algorithm. It generally divides the array into two overlapping parts (2/3 each). After that it performs sorting in first 2/3 part and then it performs sorting in last 2/3 part. And then, sorting is done on first 2/3 part to ensure that the array is sorted.
The key idea is that sorting the overlapping part twice exchanges the elements between the other two sections accordingly.
Step 1: If value at index 0 is greater than value at last index, swap them. Step 2: Recursively,
Stooge sort the initial 2/3rd of the array.
Stooge sort the last 2/3rd of the array.
Stooge sort the initial 2/3rd again to confirm.
NOTE: Always take the ceil of ((2/3)*N) for selecting elements.
This article is contributed by DANISH KALEEM. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.