Bogo Sort and Stooge Sort
Algorithm is a list of instructions
that explains how to do something.
BOGO SORT is one example of
sorting algorithm. Its name comes from the word bogus. It is a terribly
inefficient sorting algorithm that repeatedly
generates a random permutation of the items until the items are
in order. Another definition of bogo sort is that it is equivalent to repeatedly
throwing a deck of cards in the air, picking them up at random, and then
testing whether they are in order. This kind of sorting algorithm serves as a
canonical example of awfulness. It is also known as the random sort, shotgun
sort or monkey sort. This algorithm is use only for educational purposes, to
contrast it with other more pragmatic algorithms. If bogo sort were used to
sort a deck of cards, it would consist of checking if the deck were in order,
and if it were not, one would throw the deck into the air, pick the cards up at
random, and repeat the process until the deck is sorted.
These are the properties of bogo
sort:
- · Bogo sort has an expected run time of O(n!); each time it randomly sorts our lists, i.e. picks one of the n!-many various permutations, and sees if this permutation happens to order our list (and there is exactly one of these permutations when our list is made of distinct integers.)
- · Bogo sort has a worst-case run time of O (1); as if we were quite terrifically unlucky it might never randomly pick the right permutation.
STOOGE SORT is another kind of
sorting algorithm. This sorting algorithm is terribly inefficient sorting algorithm
that swaps the top and bottom items if needed, then sorts the bottom
two-thirds, then the top two-thirds, then the bottom two-thirds again. Its name
comes from slapstick routines of the three (3) stooges in which each stooge
hits the other two.
Comparing
the two kinds of sorting algorithms they are both ineffective and humorous
sorting algorithm. Bogo sort is a terribly inefficient sorting algorithm that repeatedly
generates a random permutation of the items until the items are in order while Stooge sort is an algorithm that terribly inefficient
sorting algorithm that swaps the top and bottom items if needed, then sorts the
bottom two-thirds, then the top two-thirds, then the bottom two-thirds again. As
I analyze the both algorithm, bogo sort is the better one.
Reference:
by: Camille Abigail M. Rollan
0 comments:
Post a Comment