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 3 or more elements in 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.
215 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 from http://en.wikipedia.org/wiki/Stooge...

Stooge sort (30)


Stooge Sort (Programming Tutorial)

SOURCES FOR MATERIALS USED IN VIDEO-- Music :https://www.youtube.com/watch?v=1Lj26gbb1i4 Intro: https://www.youtube.com/watch?v=x-YpzGsO0V0 Audible Example: ...

Stooge Sort

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 and Shemp.

Stooge Identification Fail

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

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 certified doctor of any sort...

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...

Bubble Sort (Programming Tutorial)

SOURCES FOR MATERIAL USED IN VIDEO-- Audible Example: http://panthema.net/2013/sound-of-sorting/ GIF: http://commons.wikimedia.org/wiki/File:Bubble-sort-example-300px.gif 25 Element Array ...

215 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