Results 1 to 9 of 9
  1. #1
    ab6301 is offline Member
    Join Date
    May 2010
    Posts
    1
    Rep Power
    0

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

    Default

    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.
    Ever seen a dog chase its tail? Now that's an infinite loop.

  3. #3
    JavaGAR's Avatar
    JavaGAR is offline Member
    Join Date
    May 2010
    Location
    Long Island, New York, USA
    Posts
    4
    Rep Power
    0

    Post

    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. #4
    m00nchile is offline Senior Member
    Join Date
    Feb 2010
    Location
    Ljubljana, Slovenia
    Posts
    470
    Rep Power
    5

    Default

    Oh my. Maybe it should be called UselessWasteOfCPUTime sort instead :D.
    Ever seen a dog chase its tail? Now that's an infinite loop.

  5. #5
    JavaGAR's Avatar
    JavaGAR is offline Member
    Join Date
    May 2010
    Location
    Long Island, New York, USA
    Posts
    4
    Rep Power
    0

    Default 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. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,003
    Blog Entries
    7
    Rep Power
    20

    Default

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

    kind regards,

    Jos

  7. #7
    m00nchile is offline Senior Member
    Join Date
    Feb 2010
    Location
    Ljubljana, Slovenia
    Posts
    470
    Rep Power
    5

    Default

    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*
    Ever seen a dog chase its tail? Now that's an infinite loop.

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,003
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by m00nchile View Post
    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. #9
    m00nchile is offline Senior Member
    Join Date
    Feb 2010
    Location
    Ljubljana, Slovenia
    Posts
    470
    Rep Power
    5

    Default

    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.
    Ever seen a dog chase its tail? Now that's an infinite loop.

Similar Threads

  1. Help with an Algorithm
    By Manfizy in forum New To Java
    Replies: 22
    Last Post: 07-03-2009, 07:16 AM
  2. O(log n) algorithm help !!!!!!
    By itseeker87 in forum New To Java
    Replies: 8
    Last Post: 09-09-2008, 05:12 PM
  3. Help with algorithm
    By susan in forum New To Java
    Replies: 1
    Last Post: 07-13-2007, 10:26 PM
  4. Help me with this algorithm
    By Marcus in forum Advanced Java
    Replies: 3
    Last Post: 07-02-2007, 01:30 PM
  5. Help with Algorithm
    By Daniel in forum Advanced Java
    Replies: 2
    Last Post: 07-02-2007, 05:51 AM

Posting Permissions

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