1. Member
Join Date
May 2010
Posts
1
Rep Power
0

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

2. Senior Member
Join Date
Feb 2010
Location
Ljubljana, Slovenia
Posts
470
Rep Power
7
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.

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

4. Senior Member
Join Date
Feb 2010
Location
Ljubljana, Slovenia
Posts
470
Rep Power
7
Oh my. Maybe it should be called UselessWasteOfCPUTime sort instead :D.

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

6. Here's a nice page about terrible sorting algorithms. My favourite is 'monkey sort' ;-)

kind regards,

Jos

7. Senior Member
Join Date
Feb 2010
Location
Ljubljana, Slovenia
Posts
470
Rep Power
7
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*

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

9. Senior Member
Join Date
Feb 2010
Location
Ljubljana, Slovenia
Posts
470
Rep Power
7
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.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•