## Some inefficient algorithms you don't need to know!

Here we have some stupidly clever algorithms that are faster in execution but slower in convergence to solution.

First candidate to introduce you is Bogo Sort. Its idea is simpler. Shuffle the numbers until it finds the correct order. Complexity of the algorithm can be approximated as O(n.n!) (efficient hah ?). Its pseudo code can be written as;

``````while not isInOrder(deck):
shuffle(deck);``````

Next one is known as Stooge Sort. The idea is to sort the initial 2/3 part then sort the final 2/3 part and cycle up to order of the numbers. Here is a 1/3 overlapping part as the guarantee the final correct order. However it is also very efficient sorting as the upper peer. Its complexity is O(n^2.7). The algorithm is written as;

``````algorithm stoogesort(array L, i = 0, j = length(L)-1)
if L[j] < L[i] then
L[i] ↔ L[j]
if (j - i + 1) >= 3 then
t = (j - i + 1) / 3
stoogesort(L, i  , j-t)
stoogesort(L, i+t, j  )
stoogesort(L, i  , j-t)
return L``````

The last algorithm is might be far clever. I called it PrintSort. The main idea here is to print the item n after n secs later. In that way we will have printed array of numbers in sorted fashion. Flashy right! Its complexity is even linear O(n) since a single iteration is required to read all the numbers and print them all. It is a little hacky method that benefits from the famous O notation.

That’s all for now. If you know any other dummy sorting method please let me know.