Sorting algorithms are precision-driven. Among all the effective and efficient sorting algorithms exists a highly inefficient and unconventional sorting algorithm – Bogo Sort. Instead of relying on strategic computation it relies on a game of chance. The pseudocode for bogo sort is given below:
function isSorted(arr): for i from 0 to length(arr) - 2: if arr[i] > arr[i+1]: return false return true function bogoSort(arr): while not isSorted(arr): shuffleElements(arr)
Bogo Sort is one of the algorithms which have the worst case time complexity of Ο(∞). This is because this technique relies on the sorted array to appear magically after a random shuffle of its elements. This is like playing the game of LUDO and hoping to roll a 6 on the die just wayy more intense. The best case scenario of this sort also like other sorting techniques occurs when the given input is already sorted.
This algorithm performs best when the work for it has been already done. i.e. when it is not needed.🤦🏻
Be First to Comment