# snailsort algorithm

• 05-09-2010, 09:26 PM
ab6301
snailsort algorithm
Hi

Im pretty new to anything maths and algorithm with java....... so my question is has anyone heard of sort method known as snail sort? I cannt seem to find any information on it or the type of big O notation it follows.......

Thanks
• 05-09-2010, 10:31 PM
m00nchile
I wouldn't know a sorting algorithm called snailsort, but I'm assuming this is part of a class, and this particular algorithm was used to showcase the less efficient (ie. O(square(n)) algorithm family. Most probably it's bubble sort, or straight insertion.
• 05-10-2010, 12:20 AM
JavaGAR
I found this code for snailsort, and it appears to be an O(n^4) sorting algorithm. Accordingly, snailsort seems an appropriate name for it.:D
• 05-10-2010, 07:09 AM
m00nchile
Oh my. Maybe it should be called UselessWasteOfCPUTime sort instead :D.
• 05-10-2010, 01:04 PM
JavaGAR
Snails and Dogs
Whoever came up with the snailsort algorithm probably had a sense of humor, so it probably was not intended for commercial use. ;)

Speaking of senses of humor, m00nchile, I like what you wrote ...
Quote:

Ever seen a dog chase its tail? Now that's an infinite loop.
We've heard of tail recursion. Perhaps we can call your dog example tail iteration. :D
• 05-10-2010, 01:27 PM
JosAH
Here's a nice page about terrible sorting algorithms. My favourite is 'monkey sort' ;-)

kind regards,

Jos
• 05-10-2010, 02:38 PM
m00nchile
There is something about code this bad, that it's practically genious. Randomly swapping pairs of elements and hoping the array gets sorted? *head explodes*
• 05-10-2010, 02:53 PM
JosAH
Quote:

Originally Posted by m00nchile
There is something about code this bad, that it's practically genious. Randomly swapping pairs of elements and hoping the array gets sorted? *head explodes*

The sequence *could* be sorted after a couple of random swaps ... compare it with non-deterministic algorithms; they *can* be very efficient.

kind regards,

Jos
• 05-11-2010, 10:54 PM
m00nchile
Yeah, that actually is just a short leap away from genetic programming. I'm looking into it just now, since it fits a project I have to do at uni like a glove.