Slowsort

Slowsort is a sorting algorithm. It is of humorous nature and not useful. It's based on the principle of multiply and surrender, a tongue-in-cheek joke of divide and conquer. It was published in 1986 by Andrei Broder and Jorge Stolfi in their paper Pessimal Algorithms and Simplexity Analysis (a parody of optimal algorithms and complexity analysis).

Algorithm

Slowsort is a recursive algorithm. It finds the maximum of the sorted array, places that maximum at the end and sorts the remaining array recursively.

An in-place implementation in pseudo code:

 procedure slowsort(A,i,j)                            // sorts Array A[i],...,A[j]
   if i >= j then return
   m := ⌊(i+j)/2⌋                            
   slowsort(A,i,m)                                    // (1.1)
   slowsort(A,m+1,j)                                  // (1.2)
   if A[j] < A[m] then swap A[j] and A[m]             // (1.3)
   slowsort(A,i,j-1)                                  // (2)

Complexity

The runtime for Slowsort is . A lower asymptotic bound for in Landau notation is for any . Slowsort is therefore not in polynomial time. Even the best case is worse than Bubble sort.

References

[1] [2]

  1. "CiteSeerX — Pessimal Algorithms and Simplexity Analysis". Citeseerx.ist.psu.edu. Retrieved 2017-07-26.
  2. "', '' + words + '', '". Wiki.c2.com. Retrieved 2017-07-26.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.