Slashdot Mirror


Sorting Algorithms — Boring Until You Add Sound

An anonymous reader writes "Anyone who's ever taken a programming course or tried to learn how to code out of a book will have come across sorting algorithms. Bubble, heap, merge — there's a long list of methods for sorting data. The subject matter is fairly dry. Thankfully, someone has found a way to not only make sorting more interesting, but easier to remember and understand, too."

28 of 118 comments (clear)

  1. QuickBasic did this by Bananenrepublik · · Score: 3, Informative

    Anybody who did their first programming steps with QuickBasic will remember that it came with a demo that did just this. Anyway, the videos are still fun to watch.

    1. Re:QuickBasic did this by commodore64_love · · Score: 4, Informative

      Ditto MS BASIC 7(?) on the old 1985 Amiga - included demos with sound.

      Plus TV shows, especially scifi ones, do this all the time. The computers don't have to make noise but the audio engineer added the sound to keep the show from being dull.

      --
      "I disapprove of what you say, but I will defend to the death your right to say it." - historian Evelyn Beatrice Hall
  2. Re:Easily amused by 0racle · · Score: 2, Insightful

    Yes

    --
    "I use a Mac because I'm just better than you are."
  3. Sorting Out Sorting by SilverEyes · · Score: 3, Interesting

    Does anyone remember "Sorting Out Sorting" (1980)? Best sorting video ever made. This is the same thing, it's good, but it was done thirty years ago. Also, "Pointy Does Pointers" (not an adult film, I swear).

    --
    Interesting.
    1. Re:Sorting Out Sorting by maxwell+demon · · Score: 2, Informative

      Do you mean this? Because as far as I can see, that one doesn't illustrate the sorting algorithm itself with sound. Disclaimer: I only watched the first three minutes.

      --
      The Tao of math: The numbers you can count are not the real numbers.
    2. Re:Sorting Out Sorting by SilverEyes · · Score: 3, Funny

      I did watch it again after I posted my comment, I was wrong. I misremembered the video. The annoying sounds are unrelated to the algorithm.

      This guy did have not-annoying sounds related to the algorithm. Also the quality is much higher.

      --
      Interesting.
    3. Re:Sorting Out Sorting by MikeTheGreat · · Score: 2, Interesting

      My initial reaction was "Really? Seriously?? How does this make the algorithm any more interesting, easier to understand, or easier to remember? I mean hey - I like 80's console-sounds as much as the next guy, but they're not really adding anything."

      Then it hit me that (apparently) many people haven't seen the algorithms visualized like this before. As someone who's been teaching this stuff for years, I've always handed out links to visualizations like this (even if they did lack the retro-hip sound effects :) ). As a matter of fact, I think that one of the first big demonstrations of Java was an applet that demonstrated
      various sorting algorithms [citation needed :) ]

      Anyways, if you're interested in this sort of thing, the link I've been using is:
      http://www.sorting-algorithms.com/

      I've heard good things about this place, but haven't looked through it extensively:
      http://algoviz.org/

      (You know, in all the years I've been on Slashdot, I don't think I've ever wanted to create a new top-level post instead of responding to someone else's comment.... until now. Which is why I can't find the button to do so. I'd love for someone to (politely, with good humor) point out the obvious button that I'm missing)

  4. No Quicksort? by gus+goose · · Score: 4, Insightful

    Feel like I'm complaining about a poll with a missing option, but, honestly ....:(

    gus

    --
    .. if only.
    1. Re:No Quicksort? by maxwell+demon · · Score: 2, Funny

      I also noticed that they have Gnomesort, but not KDEsort. :-)

      --
      The Tao of math: The numbers you can count are not the real numbers.
    2. Re:No Quicksort? by kvezach · · Score: 3, Insightful

      No thinking outside of the box -- no radix sort? Seriously!

    3. Re:No Quicksort? by Tanktalus · · Score: 3, Funny

      I was looking for Bogosort myself, actually.

    4. Re:No Quicksort? by Apocryphos · · Score: 2, Informative

      Like shit.

  5. Shear Sort by jellomizer · · Score: 3, Insightful

    The Shear Sort is one of my favorite sorts out there. Although you will need an orchestra to play it.

    --
    If something is so important that you feel the need to post it on the internet... It probably isn't that important.
  6. Try it with people by twoshortplanks · · Score: 5, Funny
    It's always more fun to do this with real people (sort by height, for example). The London Perl Mongers tried this as a drinking game: You get enough people down the pub (or, in one this case, outside a bar in portugal during conference season) and apply booze. Then bubble sort them as a group (lots of shouting Stay! Switch!.) Add drinking penalties when people screw up the algorithm. You get the idea.

    There's a video on the internet somewhere. Free pint to the first person to find it.

    --
    -- Sorry, I can't think of anything funny to say here.
    1. Re:Try it with people by siriuskase · · Score: 2, Funny

      No way, I don't want to stand near a guy who's only 5' 4". That's normal for women, but guys like that tend to have defective personalities. I like to stand near the tall guys.

      --
      If you must moderate, please moderate as irrelevent, not something bad, because I'm sure someone will find this interest
  7. As a decided non-expert... by KingAlanI · · Score: 2, Interesting

    One thing this seems to show me (at least the video does)
    the rate of completion - how much is sorted by each point in the process
    the algorithms seem to all do that a bit differently; some have most of the work completed in the beginning, some in the end.
    Most seem to take one piece of data and plunk it right in order; the merge sort seems to be the only one with intermediate groupings.
    and there's one final pass to make sure the data's in order.

    I notice different sorting processes are appropriate for different RL sorting situations.

    --
    I listen to both RIAA and non-RIAA stuff if I like the music, tangential business/politics nonwithstanding.
    1. Re:As a decided non-expert... by pjt33 · · Score: 4, Informative

      The heap sort actually has intermediate structure. If you watch carefully you can see that it has two phases, the first much shorter than the second. However, the structure isn't as visibly obvious as for merge sort.

      If it had showed quicksort (I can't understand why it didn't) then you'd have seen some intermediate structure there too.

      I also noticed that the selection sort wasn't as good as it could be. It's more efficient to select the largest and the smallest unsorted values on each pass - you halve the number of passes, and on each pass you do 50% more work, so overall it's a 25% improvement.

  8. The sound of bubble sort by Anonymous Coward · · Score: 5, Funny

    That's strange. When I listen to the sound of bubble sort all I hear is one of my college professors threatening to hunt me down and kill me in my sleep if I ever use it.

    1. Re:The sound of bubble sort by Anonymous Coward · · Score: 2, Informative

      then your profs are kinda dumb, there are plenty of times when its acceptable to use bubble sort....

      suppose you are on an embedded device, and you know that your inputs will always be limited by some factor, bubble sort also has rather good cache performance

    2. Re:The sound of bubble sort by jfengel · · Score: 2, Interesting

      And that's not uncommon. There are plenty of circumstances where you may have a large number of short lists floating around. Say, a list of a person's children, which will be less than 4 in 99% of cases and even the extreme cases aren't going to kill you. There may be many instances of the list, but each will be small.

      Sorting those lists via some O(n^2) sort is lower overhead than building up fancy data structures. Especially if you're building the lists incrementally, such as via an insertion sort (much like an incremental bubble sort).

  9. Diagnostics by PPH · · Score: 4, Interesting

    One interesting application of such audible/visual representations could be for diagnostic reasons.There are numerous cases where experienced observers can spot patterns or anomalies in patterns that machine algorithms have trouble with.

    One example I was involved in years ago at Boeing was a tool for diagnosing a large switch matrix used in a piece of automated test equipment. Each output could be tied to a high, low or open signal, driven from a controller over an HPIB bus. Failure modes included not only an output stuck high, low or open, but address bus problems where some lines would cause passive failures or activate more than one pin. After watching a poor engineer go through a suspect matrix panel for over a day, entering a command on the bus, finding the pin on a patch panel, sticking a voltmeter on it, over and over a few thousand times, we came up with a solution. Bi-colored LEDs wired to a patch panel and a program to exercise the matrix with a series of address patterns. An observer could spot a single bad switch or a hung address bus line in a few seconds just by looking for an anomaly in a couple of checkerboard and other patterns.

    --
    Have gnu, will travel.
  10. Bugged bubble sort? by Anaerin · · Score: 2, Interesting

    The bubble sort used here is kinda bogus. It iterates over the whole set on every pass, which it doesn't need to. It only needs to go over dataset-(pass-1) items. I have a feeling this will change the "sound" of the bubble sort in this example.

    1. Re:Bugged bubble sort? by Anonymous Coward · · Score: 2, Informative

      That optimization doesn't change the run-time complexity of the algorithm, it's still O(n^2). Usually bubble sort is taught without the optimization and once the student understands, you point out that particular optimization or try to get them to figure it out on their own.

  11. Re:Clown Sort by maxwell+demon · · Score: 2, Informative

    I know this as bogosort. Wikipedia also mentions random sort, shotgun sort and monkey sort as alternative names, but not clown sort. Also a Google search for "clown sort" doesn't seem to give sorting algorithm results, not even if I add algorithm as additional search term.

    --
    The Tao of math: The numbers you can count are not the real numbers.
  12. Re:Easily amused by oldspewey · · Score: 2, Funny

    I'll create an audio interface using Visual Basic ... see if I can track an IP address.

    --
    If libertarians are so opposed to effective government, why don't they all move to Somalia?
  13. Re:Sorting is a waste of time by mea37 · · Score: 5, Insightful

    If you think all that time examining sorting algorithms was intended to teach you about sorting, then you indeed missed the point. Programming courses spend a lot of time on sorting because it is a common task that can be easily understood, but for which there are a lot of different algorithms with very different performance characteristics. The point is to teach algorithm analysis skills.

    Judging from the quality of code I encounter regularly, though, you're far from alone in failing to pick up that lesson.

  14. Sorting real objects by spaceyhackerlady · · Score: 3, Interesting

    As an undergrad I worked in the university library to earn a bit of spending money, and one of my tasks was sorting books to put them back on the shelves. My colleagues used selection sort. I didn't.

    I did a first pass through the books. Two piles, typically A-L, M-Z. Then a second pass, A-D, E-L, M-R, S-Z. And so on, until the piles were small enough I could go through them and put them on the shelf in order.

    How many people do you know who actually use quicksort to sort real objects?

    ...laura