digplanet beta 1: Athena
Share digplanet:


Applied sciences






















Stooge sort
Sorting stoogesort anim.gif
Visualization of Stooge sort.
Class Sorting algorithm
Data structure Array
Worst case performance O(nlog 3 /log 1.5)
Worst case space complexity O(n)

Stooge sort is a recursive sorting algorithm with a time complexity of O(nlog 3 / log 1.5 ) = O(n2.7095...). The running time of the algorithm is thus slower compared to efficient sorting algorithms, such as Merge sort, and is even slower than Bubble sort, a canonical example of a fairly inefficient and simple sort.

The algorithm is defined as follows:

  • If the value at the end is smaller than the value at the start, swap them.
  • If there are more than 1 elements between start and end of the list, then:
    • Stooge sort the initial 2/3 of the list
    • Stooge sort the final 2/3 of the list
    • Stooge sort the initial 2/3 of the list again
  • else: exit the procedure

The algorithm gets its name from slapstick routines of The Three Stooges, in which each stooge hits the other two.[citation needed]


 function stoogesort(array L, i = 0, j = length(L)-1)
     if L[j] < L[i] then
         L[i] ↔ L[j]
     if (j - i + 1) > 2 then
         t = (j - i + 1) / 3
         stoogesort(L, i  , j-t)
         stoogesort(L, i+t, j  )
         stoogesort(L, i  , j-t)
     return L


External links[edit]

Original courtesy of Wikipedia: http://en.wikipedia.org/wiki/Stooge_sort — Please support Wikipedia.
This page uses Creative Commons Licensed content from Wikipedia. A portion of the proceeds from advertising on Digplanet goes to supporting Wikipedia.
201 videos foundNext > 

Stooge Sort

Visualization and "audibilization" of the Stooge Sort algorithm. Sorts a random shuffle of the integers [1,64] using Stooge sort. It uses the implementation ...

Stooge sort (30)


Iggy Pop - I wanna be your dog - 1979 - live

Iggy Pop - I wanna be your dog - 1979 - LIVE.

Happy Garner, Brother of a Stooge and Master of Doublespeak

Harold "Happy" Garner, lives in Gaithersburg, MD and is the brother of Paul "Mousie" Garner who performed in Ted Healey's Stooges and knew Moe, Larry, Curly ...

The Three Stooges Trailer Thoughts....

Fans have finally gotten their first look at the Farrelly Brothers passion project - The Three Stooges. http://www.HaphazardStuff.com Moe, Larry and Curly re...

The Three Stooges VCR Game-Pt. 1

Way back in the old day's of the 1980's, before the interweb and iphones, when all we had was the 8-bit NES to play games, there was a brief new form of grou...

Sean Hayes' STOOGE FEST 2012 - (episode 3)

The art of "stooging"...well, sort of.

Harper stooge attacks ailing Premier, Danny Williams, who just had heart surgery.mpg

Meanspirited is all I can say about this. The stooge in question is a former director of communication for the Canadian Prime Minister's Office. He is not a ...

the stooge's ep 1 bridge jumping

Me and my friends are all idiots do anything you see here at your own risk we have been idiots all our life's and that sort of makes us professional we can n...

Stooge Identification Fail

A 3 Stooges greeting card with authentic stooge sounds... well, sort of...

201 videos foundNext > 

1 news items

博客园 (博客)
Mon, 09 Dec 2013 22:56:14 -0800

每当成为入门CS 课程(学生们学习编程语言的课程)的助教时,都困于提出好的练习题。Project Euler 和类似的问题通常对初学者来说来难了,尤其是对于那些没有很强数学背景的同学。 在这篇文章中,Adrian Neumann 收集了 ...

Oops, we seem to be having trouble contacting Twitter

Support Wikipedia

A portion of the proceeds from advertising on Digplanet goes to supporting Wikipedia. Please add your support for Wikipedia!

Searchlight Group

Digplanet also receives support from Searchlight Group. Visit Searchlight