Everything2
Near Matches
Ignore Exact
Full Text
Everything2

stooge sort

created by jdorje

(idea) by jdorje (3.3 y) (print)   ?   (I like it!) 1 C! Thu Oct 24 2002 at 11:20:25

A stooge sort (or stoogesort) is an overly clever method of sorting a list of elements.
  1. Compare the first and last elements in the list, and swap them if they are out of order.
  2. Recursively sort the first two-thirds of the list.
  3. Recursively sort the last two-thirds of the list.
  4. Recursively sort the first two-thirds of the list again.
The algorithm itself is rather elegant, with only four steps involved. But you've got to figure there's a reason why it's named after Curly, Moe, and Larry. In fact, this problem is often used in introductory algorithms classes. The question is: how good is it? Can it compare to the fast sorting algorithms like quicksort, merge sort, or heapsort?

It should be clear that the time complexity of the algorithm is proportional to T(n)=3T(2n/3)+1. It turns out that this is actually about O(n2.71) (the master theorem/master method is helpful in determining this). Thus the sort is incredibly poor - far worse even than insertion sort, selection sort, and the venerable bubble sort.


printable version
chaos

bogo-sort spaghetti sort Time complexity bubble sort
Sorting Algorithms quicksort Merge Sort The Three Stooges
Heap Sort Heapsort Insertion Sort Selection Sort
stooge A Nightmare on Elm Street 4: The Dream Master sort strong induction
recursion Terpsichore Tao sort Swap
Elbonia Curly
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Nodes to live by:
Fuel cell
Do Not Shoot: Non-Combatant
Amélie
Satsuma
Canada
Gram-Schmidt Theorem
Dragon
scrambled eggs
Proto-Indo-European
A trip to a minimalist restaurant
Dick Whittington
From across a crowded room
Landsknecht
New Writeups
SubSane
Making Love to a 9-Foot Woman(person)
Ouzo
Thoughts(idea)
antigravpussy
I fall silent, listening. The breadcrumbs are talking about us(person)
calgon
Buffalo Bill by the pool(poetry)
gate
Anarchy is Order(idea)
ushdfgakjasgh
Scribeling(thing)
XWiz
Trism(review)
artman2003
Briefcase Full of Souls - Part I(fiction)
Dreamvirus
Alan Ladd(person)
waverider37
Harold Holt(person)
The Debutante
Until death do us part(fiction)
Ysardo
a brother to a sister(personal)
antigravpussy
your warm whispers(personal)
Clarke
Multiculturalism(idea)
aneurin
Earl of Landaff(person)
This page courtesy of The Everything Development Company