Rare · Knowledge
Bogosort
Highly ineffective sorting algorithm that successively generates permutations of its input until it finds one that is sorted
In computer science, bogosort (also known as permutation sort and stupid sort) is a sorting algorithm based on the generate and test paradigm. The function successively generates permutations of its input until it finds one that is sorted.
From Wikipedia
In computer science, bogosort (also known as permutation sort and stupid sort) is a sorting algorithm based on the generate and test paradigm. The function successively generates permutations of its input until it finds one that is sorted. It is not considered useful for sorting, but may be used for educational purposes, to contrast it with more efficient algorithms. The algorithm's name is a portmanteau of the words bogus and sort. Two versions of this algorithm exist: a deterministic version that enumerates all permutations until it hits a sorted one, and a randomized version that randomly permutes its input and checks whether it is sorted. An analogy for the working of the latter version is to sort a deck of cards by throwing the deck into the air, picking the cards up at random, and repeating the process until the deck is sorted. In a worst-case scenario with this version, the random source is of low quality and happens to make the sorted permutation unlikely to occur.
Text: Wikipédia, CC BY-SA 4.0. · Image: LKRaider (CC BY-SA 4.0) ·
Related cards
-
★★★
Bubble sort
Simple sorting algorithm
-
T★★★
Timsort
Hybrid sorting algorithm based on insertion sort and merge sort
-
★★
Insertion sort
Sorting algorithm that, at each iteration, inserts the current input element into the suitable position between the already sorted elements
-
★
BQP
Complexity class
-
★
Las Vegas algorithm
Randomized algorithm guaranteed to eventually produce correct or optimal results
-
★
Bucket sort
Sorting algorithm