A Comphrehensive guide to the worst sorting algorithms

Правка en3, от pikamonstruosa, 2023-07-15 17:12:42

With the broad availability of quick and efficient sorting algorithms, that can sort arrays in $$$O(N*logN)$$$ complexity, little space was left for the bad sorting algorithms. Because of this, I will, in this blog, explore the vast world of the bad sorting algorithms.

Bogosort

-This may be the most famous bad sorting algorithm. Its legendary strategy consists of randomly shuffling and array until it is sorted. In average, $$$(N-1)*N!$$$ swaps are made.

Code

*It is also worth mentioning that there is a variant of this algorithms that eliminates the randomness issue: Create all $$$N!$$$ possible permutations of a given array. Go through each one checking if they are ordered or not.

Bozosort

-This is another sorting algorithm that relies on randomness to be bad and the strategy it uses to sort is quite simple: If the array is not ordered, randomly select two elements of an array, swap them. The expected time complexity is a bit more complex, but on average $$$N!$$$ swaps are made.

Code

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en11 Английский pikamonstruosa 2023-12-05 17:38:37 0 (published)
en10 Английский pikamonstruosa 2023-12-05 17:09:03 274
en9 Английский pikamonstruosa 2023-12-05 16:47:14 92
en8 Английский pikamonstruosa 2023-12-05 16:42:45 890
en7 Английский pikamonstruosa 2023-12-05 16:19:08 11
en6 Английский pikamonstruosa 2023-12-05 16:11:49 1214 Tiny change: 'ted in $O(N^(Faith))$ time co' -> 'ted in $O(Faith^-1)$ time co'
en5 Английский pikamonstruosa 2023-07-15 18:02:55 1229
en4 Английский pikamonstruosa 2023-07-15 17:52:15 150
en3 Английский pikamonstruosa 2023-07-15 17:12:42 1601
en2 Английский pikamonstruosa 2023-07-14 19:59:56 227 Tiny change: 's.\n\n### ### ### Bogoso' -> 's.\n\n### Bogoso'
en1 Английский pikamonstruosa 2023-07-14 04:30:51 266 Initial revision (saved to drafts)