Slashdot Mirror


Deep Algorithms?

Stridar writes "A paper presented in a recent article quotes Donald Knuth as saying the computer science has 500 deep algorithms. He mentions that Euclid's algorithm is one of the most important, and he seems to agree with the idea that CS will be mature when it has 1000 deep algorithms. What I would like to ask Slashdot is the following. What are the most important algorithms in CS? What is your favorite algorithm? And finally, what are the outstanding problems for which algorithms would be immediately placed in the "Top 1000" category." We had an older story where two scientists picked their top ten algorithms.

570 comments

  1. Hmmm... by 42forty-two42 · · Score: 1

    Well, compiler alrogithms are important :)

    1. Re:Hmmm... by DJPenguin · · Score: 1
      I seem to remember having a write various everyday tasks (getting up, walking to school) in psuedo-code at school.


      I imagine the pseudo-code "algorithm" for making a cup of coffee would be one of the most important in CS! :)

  2. Bubble Sort? by cjpez · · Score: 2, Funny

    Does the Bubble Sort algorithm count as important?

    1. Re:Bubble Sort? by Odinson · · Score: 3, Funny
      Without bubble it would be impossible to obtain a bell curve in computer science classes.

      You're damn right it's important.

    2. Re:Bubble Sort? by Murmer · · Score: 0
      >Does the Bubble Sort algorithm count as important?

      Only because you're more likely to get it right after four pints than any of the others.

      --
      Mike Hoye
    3. Re:Bubble Sort? by G0SP0DAR · · Score: 1

      hehe! I have to agree with you there. Clearly, it is less efficient than the almighty quick sort routine. At least on paper. There are a few CS teachers who insist that bubble has some practical advantages over QS. If anyone finds out what these are, please post them, I have yet to figure it out! ;)

      --


      Calm down, it's *only* ones and zeroes.
    4. Re:Bubble Sort? by cjpez · · Score: 2

      lol. See, its uses go on and on! Soon we'll find it cleaning up the environment and solving all of the world's complicated social problems!

    5. Re:Bubble Sort? by Anonymous Coward · · Score: 0

      Bubble Sort is faster than Quicksort for data that is already mostly sorted. Quicksort will ALWAYS run at NlogN, whereas Quicksort, for data that has only one or two elements out of order, will end up effectively running at 2N or 3N.

    6. Re:Bubble Sort? by Garin · · Score: 2, Insightful

      This is a standard interview question for me, when I interview programmers. "In what case would you want to use a bubble sort?" The answer, my friends, is very simple. The bubble sort is extremely fast when your list is almost always very nearly sorted, with very few (or no) elements out of order. For some algorithms, the already-sorted order is the worst case. For the bubble sort, it's the best case. So if you have a data structure that is updated frequently, but the order of the elements very rarely changes, you can use a bubble sort without being too embarrassed. :)

      --
      In any field, find the strangest thing and then explore it. -John Archibald Wheeler
    7. Re:Bubble Sort? by PD · · Score: 1

      If you're sorting a very short list, like 10 items, a bubble sort will be all done by the time a quicksort is just getting set up.

    8. Re:Bubble Sort? by Gary+Yngve · · Score: 1

      We all know that Bubble Sort is O(n^2) while Quick Sort is O(n log n) average case [and O(n^2) worst case].

      But remember that Big-O is for asymptotic behavior. When you have to swap small amounts of elements, bubble sort is by far faster. Why? For one, Quick Sort is recursive. In fact, a good quick sort implementation will do quick sort until the chunks get small enough and then do bubble sort on those.

      There are also algorithms that do matrix multiplication in O(n^2.blah) time. The naive method is cubic. How come no one uses these fancy methods? Because they are a pain to implement and require n to be so large before they actually start performing better than the naive implementation.

    9. Re:Bubble Sort? by Phil+Wilkins · · Score: 1

      Bubble Sort retains the initial ordering of equally ranked items. Most other sorting algorithms don't.

      Other than that, simplicity of implementation. I can knock out a bubble sort without thinking, whereas anything else requires actually looking something up.

    10. Re:Bubble Sort? by Garin · · Score: 1

      Er. Nevermind about the worst case. But in -any- case, bubble sort is VERY fast when the list is already sorted. And yes, it is very useful in practice.

      The moral of the story is to always think about the reality of your data structures, and optimize for the most important and most relevant cases that you're dealing with, not to go with the slickest and coolest algorithms. Yes, Abrash is one of my heroes. :)

      --
      In any field, find the strangest thing and then explore it. -John Archibald Wheeler
    11. Re:Bubble Sort? by Matthew+Austern · · Score: 5, Insightful
      This is a standard interview question for me, when I interview programmers. "In what case would you want to use a bubble sort?"

      And the correct answer is: never.

      It's true that for small lists, or lists that are nearly sorted, you want to use an O(N^2) algorithm rather than (say) quicksort. The mistake is making the leap from "an O(N^2) algorithm" to "bubble sort".

      There are lots of O(N^2) sorting algorithms, with different constant factors. Bubble sort is one of the worst; see Knuth (v. 3, of course) for a detailed analysis. If you're dealing with a small list or a nearly-sorted list, you should probably use insertion sort. (Or, in some special cases, you might want selection sort or merge sort instead.)

      I have yet to find any case, anywhere, where bubble sort is the right choice. If I ever teach an introductory algorithms class, I will probably omit bubble sort.

    12. Re:Bubble Sort? by Anonymous Coward · · Score: 0

      It's not always less efficient it just depends on your order 1 operations.. Can you come up with a faster algorithm for quicksort than bubble sort on a turing machine?

    13. Re:Bubble Sort? by Hater's+Leaving,+The · · Score: 2, Informative

      "Quick Sort is recursive"

      Recursion adds _bugger all_ overhead.
      What kind of machine are you using - is it based on punched cards? Recursion is no more expensive than a loop overhead. How many loops does bubble-sort have to set up?

      "and then do bubble sort on those. "

      I hope not. I mean, you've got selection, insertion, in-place merge, and hard coded minimal exchange sorts to chose from; there's no need to bubble. Ever!

      "
      There are also algorithms that do matrix multiplication in O(n^2.blah) time. The naive method is cubic. How come no one uses these fancy methods? Because they are a pain to implement and require n to be so large before they actually start performing better than the naive implementation.
      "

      Yeah but the 2.blah you're thinking about is 3*ln(8)/ln(9) = 2.84. Which is damn close to 3 compared with how vastly different O(n^(1+o(1))) is from O(n^2) in the sorting examples.

      THL.

      --
      Keeping /. cynic density high since the fscking Kwhores/trolls arrived.
    14. Re:Bubble Sort? by Gary+Yngve · · Score: 2, Informative

      To address some of your points:
      Hell yeah, recursion adds overhead. If it cannot be readily optimized into iteration (such as tail recursion), you need to maintain stack frames, allocate new local variables, etc. For tree recursions, such as quick sort (pick a pivot and resursively screw with each side), it is very hard to make the algorithm iterative without implicitly mimicing recursion or a stack.

      Yes, I was not thinking perfectly when I claimed that a good quick sort implementation would use bubble sort when the chunks got small enough. They may use some other quadratic sort. But I am still willing to bet, that when tuned properly, using the bubble sort then is more efficient than using quicksort all the way down. I don't want to make any claims about performance on various architectures because it all boils down to freakly things such as cache hits. When I try to explain things for the layman, sometimes some details slip by, just waiting for the tight-assed dork to jump on.

      By 2.blah, I was actually referring to the better results, rather than the boring divide-and-conquer method you cited. I recall results as good as n^2.23 or so, and I believe it is still unproven if matrix multiplication can be quadratic.

    15. Re:Bubble Sort? by Garin · · Score: 3, Insightful

      Never? Can you prove that there are no data structures and change patterns that do not result in the bubble sort being the fastest over all? I'd be very interested to see that proof.

      I still maintain that there may be a situation in which a bubble sort is the right choice, and that the question is a good one. Maybe I can't think of it (and honestly, I've never used a bubble sort in any code I've written) and apparently neither can you.

      For me, the most important thing to think about is to consider the situation in which you're using the algorithms. I ask the question, because I want to challenge the person I'm interviewing. The people who immediately laugh and say "Never!!" without thinking about it for a minute get passed over. If someone thought about it for a minute and replied what you did, I'd be happy with that. I'd be just as happy if someone thought about it for a minute and said, "maybe some cases in which the list is already sorted, but I'm trying to imagine how that would work".

      There may be a pattern to the way the data is changed over time that means that bubble sorts will be the best. I want people to think about that, rather than laugh about the bubble sort as a terrible algorithm. It's not -- it does what its supposed to do and nothing more. It just may be an algorithm that has an extremely narrow range of applicability.

      I would definitely teach the bubble sort, even if the lesson is, "sometimes there are simple and easy-to-use algorithms that are rarely the most useful." People have to learn to recognize that.

      --
      In any field, find the strangest thing and then explore it. -John Archibald Wheeler
    16. Re:Bubble Sort? by Hater's+Leaving,+The · · Score: 1

      People do code mimicked stacks though. I do, if I need to (though I'm more of a merge or heap man myself). Register windowing, and branch prediction have made recusion less of a pain too.

      So I certainly shouldn't say that there's no overhead, but the overhead is _really small_ compared with the rest of the job that needs to be done. O(n ln(n)) kicks in really quickly for sorts. I'll heap 20 things if there's a chance it might baloon to 30, say.

      Actaully I was wrong about the 2.84, it's 3*ln(7)/ln(8) = 2.80 (7 from 8 not 8 from 9!).
      Strassen's IIRC.

      Indeed theres a ~2.3 theoretical method (Winograd), but the scaling constant is huge, and for most purposes the algorithm is of no use for anything short of unimaginable.

      Having said that, they probably said that about some bignum algorithms, and look at what GIMPS are playing with currently.

      THL.

      --
      Keeping /. cynic density high since the fscking Kwhores/trolls arrived.
    17. Re:Bubble Sort? by r00tarded · · Score: 1

      i wouldnt omit it. its a great introduction to how not to sort. people seem to sort using bubble sort naturally. so its a great way to introduce the entire science behind sorting, by doing a bubble and then showing a quick or merge.

    18. Re:Bubble Sort? by compwiz3688 · · Score: 1

      Other than that, simplicity of implementation. I can knock out a bubble sort without thinking, whereas anything else requires actually looking something up.

      And figuring out the differences (features, [dis]advantages)between all the other sorting algorithms. I had an algorithm exam (sorting was one of the sections) 3 months ago, and now I can't remember what the difference is between insertion and selection (again).

      Also, bubble sort is the first algorithm anybody would learn (except maybe those advanced kids), and probably the most "memorized".

    19. Re:Bubble Sort? by harlows_monkeys · · Score: 2
      Other than that, simplicity of implementation. I can knock out a bubble sort without thinking, whereas anything else requires actually looking something up.

      If you need to look up straight selection sort, you've got problems. It is simpler than Bubble Sort, and it is twice as fast.

    20. Re:Bubble Sort? by khuber · · Score: 3, Interesting
      Bubble Sort retains the initial ordering of equally ranked items. Most other sorting algorithms don't.

      Merge sort does, and it is much more efficient. That is to say it's a "stable" sort. That is one reason why the C library qsort() is often implemented as a merge sort!

      All sort algorithms can be made stable by putting the original positions into the keys you are sorting.

      -Kevin

    21. Re:Bubble Sort? by rope · · Score: 1

      You should consider that you can build infinite number of stupid alghorithms that will be best in some situations. Etc. swap 1st and last element, look if data is sorted and then perform some sort algorithm. This will be the best method if only this two elements are on wrong positions. And it should be used sometimes. And if someone ask you: "Do you sometimes need this stupid sort?" and you answer:"No" you will not get job?!

    22. Re:Bubble Sort? by Anonymous Coward · · Score: 0

      Nobody here has presented a reasonable analysis of the actual cost: i.e.

      Cost = Cost to program + (Number of sorts * cost of avg sort) + cost to maintain.

      This is how any sensible decision should be made.

      On a historical note,

      In the good old days (i.e. before C), we used to use quicksort only in the case when A. there were probably more than 10 elements to sort and B. we had enough core memory (yes, actual magnetic rings) to hold the list (this was rare, as often the whole machine was only a few dozen KB).

      In the vast majority of cases, we used a merge sort on three or more tape drives, as everyone knew tape sorts were faster than disk sorts (as merge sort is sequential-IO based).

    23. Re:Bubble Sort? by Garin · · Score: 3, Insightful

      It's more like you have to consider real-life situations individually. My point is very much like what you said -- you can construct a zillion different algorithms to do something, but the vast majority of them will be practically useless in anything but a really weird situation. Recognizing when they are and aren't useful is an important skill. And most of the time, you'll go with the tried-and-true quicksorts etc.

      However, it's important to think about each situation. Pure algorithms are usually designed with the general case in mind. Individual situations, however are always specific cases. Most of the time, the general solution is obviously useful. Sometimes, however, there is a special case that might not fit the mold, and one of these crazy one-off algorithms might fit the bill exactly.

      In my mind, you will not get a job with me if you cannot see what makes each application of an algorithm unique. Computer science optimizes the general case. Real-life programming optimizes the special case that you're dealing with in your particular program.

      --
      In any field, find the strangest thing and then explore it. -John Archibald Wheeler
    24. Re:Bubble Sort? by adminispheroid · · Score: 2, Funny
      But in -any- case, bubble sort is VERY fast when the list is already sorted. And yes, it is very useful in practice.
      I recently invented an even faster sort for the case that the list is already sorted:
      #define lightning_sort(x) (x)
      Unfortunately, it only works in that one case.
    25. Re:Bubble Sort? by patchmaster · · Score: 3, Interesting

      Bubble sort is frequently the right choice and, more often, the "good enough" choice. I learned this the hard way a long time ago. Unless you're sorting at least tens of thousands of items, with today's computers it's unlikely the user will notice any difference in execution time regardless of the sort algorithm used.

      Bubble sort has the huge advantage that it can be programmed in about five minutes without reference to any algorithm book and it's simple enough you're unlikely to make any mistakes.

      Academia has incorrectly given bubble sort a bad rap. The same could be said about the "goto", but that's a different discussion.

    26. Re:Bubble Sort? by Anonymous Coward · · Score: 0

      What about bogo sort (randomly rearranging the array elements until they're sorted)?

    27. Re:Bubble Sort? by Mr+Z · · Score: 1
      All sort algorithms can be made stable by putting the original positions into the keys you are sorting.

      Thanks, I was just about to say that. It's an oft overlooked property, too. I generally feel that a sorting algorithm's stability is overrated, since you can easily tack it onto any sort, usually for a low cost. If you're sorting an array, all you need to do is compare the two pointers to break ties. It's that simple. It *does* get more complicated if you're sorting some other structure, such as a linked-list -- then you're stuck with an O(N) assignment phase before the sort, potentially, and that brings with it extra storage requirements.

      --Joe
    28. Re:Bubble Sort? by Anonymous Coward · · Score: 0

      I hope that you realize that sorting is one of the most overrated aspects of programming. It rarely, if ever, comes up in real-world programming situations. In 25 years as a professional (read: getting paid) programmer, I've only had to sort three times.

    29. Re:Bubble Sort? by Bush+Pig · · Score: 0

      Let's face it - with a lot of data, you'll _always_ be better off with a (disk based imitiation of a) N-way tape sort. Bubble sort, insertion sort, quicksort, ... are only usable if you can fit all your data into memory (although that's getting easier these days).

      --
      What a long, strange trip it's been.
    30. Re:Bubble Sort? by Anonymous Coward · · Score: 0

      For sorting nearly-sorted elements try the insertion sort routine. Very fast. Completely sorted is the best vase, completely random is worst case. Requires same amount of memory as bubble sort.
      Bubble sort if great for code which is needed right away (fast implementation), or when sorting a small number of items infrequently (ie, optimise another part of the code)

    31. Re:Bubble Sort? by Anonymous Coward · · Score: 0

      Why be flip about a bubble sort? Would you write a different sort for an array of say 10 elements? What about 100? 1000? somewhere the bubblesort is the wrong method, but I lets not stroke our egos too much because we would never use a bubble sort.

    32. Re:Bubble Sort? by erc · · Score: 1
      This is a standard interview question for me, when I interview programmers. "In what case would you want to use a bubble sort?"

      And the correct answer is "who cares?" When's the last time you had to figure something like that out? An interview isn't a trivia contest, maybe you ought to re-evaluate your interviewing style. I personally never ask this sort of nonsense in an interview, it's completely irrelevent to modern day business programming.

      --
      -- Ed Carp, N7EKG erc@pobox.com PGP KeyID: 0x0BD32C9B What I'm up to: http://intuitives.mine.nu
    33. Re:Bubble Sort? by erc · · Score: 1
      Hell yeah, recursion adds overhead. If it cannot be readily optimized into iteration (such as tail recursion), you need to maintain stack frames, allocate new local variables, etc. For tree recursions, such as quick sort (pick a pivot and resursively screw with each side), it is very hard to make the algorithm iterative without implicitly mimicing recursion or a stack.

      And there are many cases where you really can't easily get away from recusion. Searching n-levels of directories, for example.

      --
      -- Ed Carp, N7EKG erc@pobox.com PGP KeyID: 0x0BD32C9B What I'm up to: http://intuitives.mine.nu
    34. Re:Bubble Sort? by Alsee · · Score: 3, Interesting
      "In what case would you want to use a bubble sort?"
      And the correct answer is: never.


      Off the top of my head I can think of at least three major factors BubbleSort has in it's favor.

      The fastest to write.

      The lowest chance you will write a bug into it.

      The best known. Any programmer who sees the comment /*BubbleSort*/ will have instant and complete understanding of your code. It is also the easiest to spot when it isn't commented.

      BubbleSort is often the best choice for trivial tasks. A rock may not be the best tool for any job, but sometimes it is the simplest and most convient.

      -

      --
      - - You can't take something off the Internet! That's like trying to take pee out of a swimming pool.
    35. Re:Bubble Sort? by Anonymous Coward · · Score: 0

      I am sure that means that you have only had to write your own sort three times. If you have only had to sort data three times in 25 years, you do not write much code.

    36. Re:Bubble Sort? by Anonymous Coward · · Score: 0

      A bubble sort is good for small data that you know is super increasing. ie every element in your list is bigger than the combination of all
      other elements in your list. ex 1 2 4 8 16 32 etc..

    37. Re:Bubble Sort? by Anonymous Coward · · Score: 0

      Twice the speed; twice the memory. Seriously, selection is good when we want to write data to disk, but I can hardly think of an other time where selection is the best choice.

    38. Re:Bubble Sort? by zCyl · · Score: 2

      I have yet to find any case, anywhere, where bubble sort is the right choice.

      That's because of your definition of "right choice". Bubble sort is complete crap, of course. But let's say hypothetically you are writing a program in some obscure scripting language that you just learned an hour ago, you want to sort less than a thousand elements, and you want to write the program in a few seconds. Do you implement an efficient sorting algorithm? No. You type in the quickest thing possible to get the job done. For an administrator, the most common programming is probably quick hack jobs to get something done with very little invested programming time. For software development, sorts should be modular, and bubble sort can be thrown in for a prototype since it's so quick to type up, then replaced with something useful later. It's often easier to develop a program by getting it to do SOMETHING as early as possible, and then incrementally modifying it to be efficient, extensible, and adhere to specifications. The crap algorithms are useful for this intermediate step.

    39. Re:Bubble Sort? by coyote-san · · Score: 5, Interesting

      Why are you writing sorting routines anyway?

      The fastest sort to write is the call to the library sort. qsort().

      The lowest chance of writing a bug into a sort is the library sort. qsort().

      The best known sort is the library sort. qsort().

      Obviously other languages may have different library sorts, but IMHO any C/C++ developer who claims ignorance of qsort() is immediately and ruthlessly demoted to "2 years experience with little likelihood of succeeding in the field" category. This is a hard line, but I have yet to hear any reasonable excuse for being ignorant of the basic tools of your profession and being proud of it.

      There are rare circumstances where I'll write my own sorts... but only after looking HARD for a way to call the library sort, and only because I've had a full year of graduate-level algorithms. Writing a good sort routine is *hard*, and it should only be done by people who know sorts cold. E.g., can you provide the running time and worst case performance of quick sort, Shell sort and heap sorts, and when those sorts might be worth the the effort instead of using the standard library sort?

      --
      For every complex problem there is an answer that is clear, simple, and wrong. -- H L Mencken
    40. Re:Bubble Sort? by colmore · · Score: 2

      Actually, even in those cases, there are better algorithms that run in a similar amount of time.

      But running time isn't the only consideration.

      In applications where speed of production matters more than speed of operation. (Prototyping, scripting, etc. etc.) bubble sort is just fine. it can be coded quickly with minimal debugging.

      unless your job is doing data structures all the time, you'll probably have to look up QuickSort and go through a few debug cycles to get the thing working. there are times when this inconvenience outweighs performance considerations.

      (for instance, in a timed coding contest, such as the one mentioned the other day, i'd use a simpler sort to save time to concentrate on the more difficult aspects of the program)

      of course i'm not advocating this for final, published, software in any case i can think of.

      --
      In Capitalist America, bank robs you!
    41. Re:Bubble Sort? by Anonymous Coward · · Score: 0

      Never say never ;-)

      Bubblesort is a useful and effective (though not the most effective) approach to external sorting (e.g. when the sorted array is too large to fit in memory)

    42. Re:Bubble Sort? by Stary · · Score: 2
      Actaully I was wrong about the 2.84, it's 3*ln(7)/ln(8) = 2.80 (7 from 8 not 8 from 9!). Strassen's IIRC.

      Indeed theres a ~2.3 theoretical method (Winograd), but the scaling constant is huge, and for most purposes the algorithm is of no use for anything short of unimaginable.

      Not only for most purposes... for all purposes. In order for this algorithm to be useful, n has to be larger than the amount of atoms in the universe...

      --
      Tomorrow will be cancelled due to lack of interest
    43. Re:Bubble Sort? by a+random+streaker · · Score: 1

      Actually, there are other N2 sort algorithms that are better than bubble sort, so you wouldn't even use that on the small arrays at the end of quicksort.

      As a TA once told my class, "Don't use bubble sort. It's dumb."

      It is, though, not the worst sorting method. The worst was permutation sort, where you permuted the items, checked if they were sorted, then permuted them again and again until they were sorted.

      --
      "All representatives are busy. The estimated hold time is one..hundred..sixty..four..minutes." Detroit Edison, 02/01/02
    44. Re:Bubble Sort? by a+random+streaker · · Score: 1

      Actually, since you have to run through all the items to make sure they're sorted, you can't do better than O(n).

      Even where the cardinal value of the keys are the ordinal value in the sort (e.g. key translates directly to position in an array), you're still at O(n).

      Besides, I can define a faster lightning sort as long as you rely on side effects rather than on return value.

      #define lightning_Flash_wins_over_Superman_sort(x)

      That's the old Barry Allen flash, by the way.

      --
      "All representatives are busy. The estimated hold time is one..hundred..sixty..four..minutes." Detroit Edison, 02/01/02
    45. Re:Bubble Sort? by a+random+streaker · · Score: 1

      I've always found selection sort to be easier to program and understand than bubble sort.

      You are right, though, about time not being much of an issue anymore. Why even bother with linked lists when you can just load all the stuff into a giant array? For $200 you can get a Gig of RAM.

      I've even used gigantic arrays for database storage in a CE device. They are, after all, identical to a random access file of fixed record size, one of the cornerstones of computer science as data processing.

      --
      "All representatives are busy. The estimated hold time is one..hundred..sixty..four..minutes." Detroit Edison, 02/01/02
    46. Re:Bubble Sort? by a+random+streaker · · Score: 1

      OMG did I have a problem with qsort once.

      About 10 years ago when C++ was still fairly new, I had a project at grad school where I had to sort something. The compiler compiled but the program crashed. I checked and checked and checked, but there was nothing wrong with my program.

      Not one damned thing.

      It turns out the qsort was a C library, but I was calling it from a .cpp file. Thus the C function in the .cpp file was C++ call stack oriented, and the callback from qsort choked.

      The compiler was too stupid to recognize this for some reason.

      It's several incidents like that that have made me a brutish, hulking figure who swears, drinks beer, and loathes "God" the way Mark Twain used to.

      --
      "All representatives are busy. The estimated hold time is one..hundred..sixty..four..minutes." Detroit Edison, 02/01/02
    47. Re:Bubble Sort? by a+random+streaker · · Score: 1

      > Do you implement an efficient sorting
      > algorithm? No. You type in the quickest thing
      > possible to get the job done.

      Exactly! That's why you'd program selection sort or extraction sort instead of bubble sort.

      Hell, I don't even remember any of them exactly. I'd write a double loop that pulled the highest key out on each decreasing n value. Which one was that now?

      --
      "All representatives are busy. The estimated hold time is one..hundred..sixty..four..minutes." Detroit Edison, 02/01/02
    48. Re:Bubble Sort? by vocaro · · Score: 1

      If you're building software for a desktop, I agree with you. But I build embedded devices. Here, the argument is not simply a matter of speed. You also have to consider the size of the temporary memory needed for the algorithm, and the size of the algorithm's code itself.

      What if you had to build an embedded device with, say, 4KB of RAM and 1KB of ROM (for executable code)? This type of device wouldn't even have an operating system, and with such limited amounts of memory, you'd want to save every byte. With the recursive quicksort, you'd have to implement a stack (very unsafe in this example!). Other very fast sort algorithms might require large amounts of extra scrath memory (such as the bucketsort). In the end, the bubblesort, with its very small implementation size, simple design, and limited memory requirements, might actually be one of the best choices when memory efficiency is far more important than speed.

      (Never say never!)

    49. Re:Bubble Sort? by cjpez · · Score: 2

      Yes, I have a deep and undying hatred of Bubble Sort and feel compelled to mock it openly at every opportunity. I need to do this because otherwise my ego would deflate to the point that I'd be a miserable stain of biologic waste slithering around on the floor.

    50. Re:Bubble Sort? by magnusk · · Score: 1

      For lists of N items with a *constant* number of out-of-order items, both insertion sort and bubble sort are O(N), not O(N^2). IIRC, the runtime of bubble sort is typically better in this situation.

    51. Re:Bubble Sort? by zoon0 · · Score: 1

      Him: This is a standard interview question for me, when I interview programmers. "In what case would you want to use a bubble sort?"
      You: And the correct answer is: never.
      Me: Never say never.

      Aren't you assuming that programmer time has insignficant cost compared to program run time?

      And didn't someone famous say 'Premature optimization is the root of all evil'? Aren't they half right?

    52. Re:Bubble Sort? by sir99 · · Score: 1

      If you're using C++, Stroustrup claims that STL sort() is faster than qsort(), because it gives the compiler a chance to optimize your code. Of course, it also bloats your program for the same reason.

      --
      The ocean parts and the meteors come down
      Laid out in amber, baby.
    53. Re:Bubble Sort? by Matthaeus · · Score: 1

      Actually, since in bubble sort you have to compare each element to all the others after it, it's O(n^2). (k*n(*n-1))/2 if you wanna be specific, where k is the number of primitive operations in the innermost loop.

    54. Re:Bubble Sort? by Matthaeus · · Score: 1

      All of the following criteria would have to be met for me to use bubble sort:

      1. I don't have any code handy to implement a different type of sort.
      2. n 50 (depending on the machine)
      3. The program is due in 5 minutes.

    55. Re:Bubble Sort? by Garin · · Score: 2

      Sounds good to me. There's a situation where the bubble sort is the best thing to use. :)

      One of the answers I can come up with is that you can use the bubble sort method when really do want the items to bubble up naturally and somewhat slowly. That is, the goal is not necessarily to completely sort everything in the smallest amount of time/space, but more like to have the list slowly tend toward sortedness, even as it may be changing and diverging from sortedness.

      The thought is that it may be useful to do a single pass of the bubble sort, then do other stuff which might even occasionally mess up the order a bit more, then go through for another pass, and so on and so on. So as time goes on, the list stays more or less sorted, and it sorts organically and smoothly, but is rarely in perfectly sorted order.

      Yeah, it's a liberal interpretation, but that's fine. I'm not sure where it would be useful, but I bet I'll find a use for it one day.

      --
      In any field, find the strangest thing and then explore it. -John Archibald Wheeler
    56. Re:Bubble Sort? by joto · · Score: 2
      It'd better be. For almost any situation, it is better to rely on your own sorting routine, than C's standard librarys qsort.

      Case in point:

      1. the algorithm qsort uses is undocumented (it's said to be "quicker sort", which nobody seems to really know what is, but most people tend to assume is quicksort).
      2. It relies on function pointers to do comparison, etc. That has to be slow.
      3. Because of it's need to be overly general, the interface is too complex to remember, and just writing your own sorting routine is probably more maintainable.

      On the other hand: STL's sort is:

      1. Well, still somewhat undocumented in what it does, but at least it offers you the choice between a simple sort and a stable_sort.
      2. Fast, because it relies on templates, and not function pointers.
      3. Relatively easy to understand, considering you have a basic understanding of STL.

      Does STL sort bloat your program? Yes, if you use it lot's of places for lot's of different kinds of arguments. Is this bad? No, you would get that kind of bloat anyway, if you had to write each sort-routine individually. For most tasks, moderately bloated binaries are a better tradeoff than overly complex interfaces or slower code due to generality through function-pointers, boxing of values, etc...

    57. Re:Bubble Sort? by sir99 · · Score: 1

      Thanks for the explanation of my rather quick comment. I should clarify that I meant using sort() will bloat your code more than qsort() would, not necessarily that sort() would bloat the code unacceptably. I actually haven't had the opportunity to use either, since as one other poster said, it's not often necessary to sort anything in most programs.

      --
      The ocean parts and the meteors come down
      Laid out in amber, baby.
  3. What's the definition of "deep"? by Anonymous Coward · · Score: 0

    Does it have some sort of technical meaning here? I never encountered that word in my Algorithms course, that's for sure.

    1. Re:What's the definition of "deep"? by Anonymous Coward · · Score: 0

      "deep" refers to its mathematical meaning, as in the phrase "this is a deep result". These are natural gems in the fabric of logic, as opposed to dirty hacks that get the job done.

    2. Re:What's the definition of "deep"? by marktwen · · Score: 1

      I.e., it's not the type of question that comes with a multiple-choice answer. Viz., modern university education can't even come close to teaching it.

  4. Binary Search by G0SP0DAR · · Score: 1

    Without binary search, life as we know it would not exist.

    --


    Calm down, it's *only* ones and zeroes.
    1. Re:Binary Search by Hater's+Leaving,+The · · Score: 5, Informative

      Gotta agree with you, but not on its own.

      I can't narrow it down to about 50, personally. Here're the broad-brush "highlights":

      a) All of quicksort, mergesort, heapsort and radixsort.

      b) FFT, DFT, their relatives, whilst I'm divide and conquering. Convolutions and shite too.

      c) Graph algorithms including Kruskal's, Dijkstras. Coloring algorithms (useful for compilers).

      d) Parsing algoriths, while I've got compilers in mind

      e) String matching algoritms ditto

      f) Compression algorithms - Huffman, Arithmetic, LZ*, BWT.

      g) Cryptographic algorithms - Hashes, Private Key Fiestel Networks, Public Key 'bignum' techniques. I'll throw in CRCs here too as they're close to hashes.

      h) Bignum algorithms - Karatsuba, Barrett, Montgomery, Oooh, I've had FFTs already, can I have them again?

      i) Pure Maths - Euclid, XGCD. Addition Chains (e.g. Pippinger). Eratosthenes, Bernstien-Atkin likewise.

      j) Trial division, Fermat's Method, Brent/Pollard Rho, Pollard/Williams P+/-1, Lenstra's ECM, Quadratic Sieve, (S/G)NFS.

      k) Applied Maths - Newton-Raphson, Runge-Kutta, Tchebyshev interpolation.

      Too many to count...

      THL

      --
      Keeping /. cynic density high since the fscking Kwhores/trolls arrived.
    2. Re:Binary Search by Hater's+Leaving,+The · · Score: 0, Offtopic

      Where I'm from the noun form of leaving is an exact obverse of arrival.
      /please pick up an id card on arrival and hand it to a steward on leaving./
      Sure, it has forms where a swap doesn't make sense.

      I also think I was trying to mimic the word-lengths at the time (love/hate has it, email addy has it). (It was a long time back.)

      I'm amazed people get the reference still.

      Well, here come some nice -1 Offtopics...

      Unless I mention the THL parody algorithm?

      Phil

      --
      Keeping /. cynic density high since the fscking Kwhores/trolls arrived.
    3. Re:Binary Search by banka · · Score: 0

      well if quick and radix sort made it, you should definitely include odd-even and the "shear sort", they are incredibly fast parallel sorting algorithms,

      "Odd-Even Transposition Sort is a parallel algorithm, with an worst case time of O(n), running on n processors. Its absolute speed up is O(log n), so its efficiency is O((log n)/n).

      Shear Sort is a parallel algorithm, with an worst case time of O(n1/2 log n), running on n processors. Its absolute speed up is O(n1/2), so its efficiency is O(1/n1/2)."
      taken from here

    4. Re:Binary Search by G0SP0DAR · · Score: 1

      True. I suppose the binary search would be more or less directly dependent on the quick sort for any reasonable amount of efficiency

      --


      Calm down, it's *only* ones and zeroes.
    5. Re:Binary Search by Hater's+Leaving,+The · · Score: 1

      Funnily enough that list was just the /small/ set of algorithms that I come in contact with almost every day (I'm a softie & mathematician). I live in my own small world.
      I was hoping to see lots of other lists from people who work and think in other fields. I'm sure there are a vast number of Chemists, Physicists, and Engineers, for example, who could open my eyes when it comes to algoritms. (Applied maths was never my strong point)

      Ditto with more high-tech Comp-Sci algorithms.

      Thanks for posting those, it's a shame you're sitting there at Score 0, as I nearly missed your reply. I shall look them up (and snarf the papers for fun future bus-journey reads).

      THL.

      --
      Keeping /. cynic density high since the fscking Kwhores/trolls arrived.
  5. My pick goes for RSA by dgerman · · Score: 4, Interesting


    THe algorighm is simple, powerful and beautiful. Its properties allows to use for encryption or for authentication. It is simple enough that can be described in a piece of paper, and understood with basic mathematical background, and it affected the e-world in many different, some of them still to be seen.

    1. Re:My pick goes for RSA by halfpastgone · · Score: 1

      on a somewhat similar note: Cayley-Purser algorithm

      --
      "I can't understand why people are frightened by new ideas. I'm frightened of old ones."
    2. Re:My pick goes for RSA by B.D.Mills · · Score: 2

      It is simple enough that can be described in a piece of paper...

      Any algorithm can be described on a piece of paper, provided you can get pieces of paper that are large enough.

      --

      The only thing necessary for the triumph of evil is for good men to do nothing. - Edmund Burke
    3. Re:My pick goes for RSA by TedCheshireAcad · · Score: 3, Insightful

      No way man the Number Field Sieve ownz RSA.

      :-)

    4. Re:My pick goes for RSA by r00tarded · · Score: 3, Insightful

      or a infinately long tape divided into squares, each of which is inscribed with a 0 or 1. fed into a machine...

    5. Re:My pick goes for RSA by Traxton1 · · Score: 1
      It's got nothing on rot13 ;)

    6. Re:My pick goes for RSA by Nightpaw · · Score: 2

      or a infinately long tape divided into squares, each of which is inscribed with a 0 or 1. fed into a machine...

      Hey, what if you used some kind of ferrous material embedded in a tough substrate and encoded the 0s and 1s electromagnetically?

  6. Are sorting algorithms "deep"? by sh4de · · Score: 1

    Quicksort is my personal favourite, and while I haven't ever implemented it in C (not reinventing the wheel etc.), I did code a MC68k assembly version in late 80s.

    Radixsort looked a lot like magic at first sight. It was very common on the Amiga, mainly for sorting the Z buffer in one's l33t 3D routines. :)

    1. Re:Are sorting algorithms "deep"? by a_n_d_e_r_s · · Score: 2, Funny

      I just live the bubble sort.

      It is also the best algorithm to use to
      sort a list....

      ...

      ... when there a few items in the list.

      --
      Just saying it like it are.
    2. Re:Are sorting algorithms "deep"? by Tony+Hoyle · · Score: 2

      I read in Dr.Dobbs years ago of someone who'd modified a bubble sort so it could outperform a quicksort... it worked, too. He called it a 'comb sort' but I've not seen anything of it since.. I expect his figures were a bit too optimistic (I wish I could remember the algorythm... all I can remember was it was almost exactly the same as a bubble sort with a few lines changed).

    3. Re:Are sorting algorithms "deep"? by Hater's+Leaving,+The · · Score: 3, Interesting

      There's a clever derivative called "Shell short", which might be what you're refering to.
      It sends coarse combs across the data at first
      Then it sends finer ones, and finally the last comb is the same as the 'exchange consecutive elements only' step in quicksort.

      However, whilst it appears similar, it's actually very different because it uses an iterative refinement, first coarse, then medium, then fine. The number of phases is normally much closer to about n^0.4 in typical implementations, rather than n in BS.

      To say it's like bubble-sort is to say quick-sort is like radix-sort. In some ways it's true, but it misses a lot of the point.

      (One pass of an in-place binary radix sort is just like one pass of a quick-sort - notta lotta people know that! You lose the order-preserving nature, but you gain in-place. Basically you hard-code the pivots to be the odd multiples of decreasing powers of 2. b10000..., then b01000... and b11000... etc.)

      THL.

      It's in Knuth.

      --
      Keeping /. cynic density high since the fscking Kwhores/trolls arrived.
    4. Re:Are sorting algorithms "deep"? by Hater's+Leaving,+The · · Score: 1

      "
      Then it sends finer ones, and finally the last comb is the same as the 'exchange consecutive elements only' step in ...
      "

      bubblesort.

      Not
      "
      quicksort.
      "

      Ooops.
      I hope it was obvious that was a simple braino.

      THL.

      --
      Keeping /. cynic density high since the fscking Kwhores/trolls arrived.
  7. Algorithm for dealing with PHB by MountainLogic · · Score: 0, Redundant

    More Detail <-------|
    | |
    V |
    (Too mch detail) |
    | |
    V |
    Less Detail |
    | |
    V |
    (Too little Detail) |
    | |
    +--------------|

    The only problem with this algorithm is that there is no exit point without killing the PHB thread.

    -s

  8. Knuth is God! by Anonymous Coward · · Score: 0

    nuff said!

    rho

  9. Mandelbrot set fractal generation by PyroJimmy · · Score: 2, Interesting

    Purely to add a little bit of the aesthetic to the list. [Check it out]

    1. Re:Mandelbrot set fractal generation by Anonymous Coward · · Score: 0

      Mandelbrot is not an algorithm. It never terminates

    2. Re:Mandelbrot set fractal generation by sir99 · · Score: 1

      Of course it terminates. It terminates when you reach the desired accuracy (just like Newton-Raphson iteration).

      --
      The ocean parts and the meteors come down
      Laid out in amber, baby.
  10. Miller-Rabin by entrager · · Score: 1

    My vote goes to Miller-Rabin.

    Prime numbers = fun for the whole family.

  11. my favorite by Anonymous Coward · · Score: 0, Funny

    the failed first post algorithm

  12. My favorite algorythm by Matey-O · · Score: 0, Troll

    10 a=a+1
    20 print a
    30 goto 10

    [ducks...runs out]

    --
    "Draco dormiens nunquam titillandus."
    1. Re:My favorite algorythm by Capt.+DrunkenBum · · Score: 1

      Well, that is one to my personal favorites.. Although I use "x" instead of "a"...

      Classy. :)

      --

      Not everyone deserves a 320i

    2. Re:My favorite algorythm by geophile · · Score: 2

      First of all, it's "algorithm". Second, an algorithm, by definition, terminates...

    3. Re:My favorite algorythm by Gary+Yngve · · Score: 1

      If all algorithms, by definition, terminate, then the Halting Problem is easily decidable.

    4. Re:My favorite algorythm by Gary+Yngve · · Score: 1

      There are many common randomized algorithms that have an expected running time that is linear but could potentially run forever. A simple example is the rejection method.

      For example, suppose I had two coins and had to pick a random number from {1,2,3}. I could do the following scheme:
      Flip the two coins. If I got:
      HH I picked 1.
      HT I picked 2.
      TH I picked 3.
      TT Flip again.

    5. Re:My favorite algorythm by protonman · · Score: 2, Informative

      Er... no. You're wrong.

      Here I'm citing from my "Introduction to the Theory of Computation" book from Michael Sipser from MIT (ISBN: 0-534-94728-X):

      "Informally speaking, an algorithm is a collection of simple instructions for carrying out some task."

      There probably is a real definition somewhere but I think it sufficies to say that algorithms are things done by Turing Machines (that's why Turing invented them in the first place), and since the a=a+10 stuff from the parent can be done by a TM, it's an algorithm.

      --
      The man of knowledge must be able not only to love his enemies but also to hate his friends.
    6. Re:My favorite algorythm by walt-sjc · · Score: 3, Funny

      Just run it under Windows and it terminates eventually just fine! Therefore it's an algorithm!

      (I hated to lose the ability to mod, but I couldn't resist! :-) )

    7. Re:My favorite algorythm by Gary+Yngve · · Score: 1

      That's the definition I go by. Basically the Church-Turing Thesis. Algorithm == Turing Machine.

    8. Re:My favorite algorythm by Doppler00 · · Score: 1

      I wrote a program like that on an Apple II in 3rd grade. I asked the class go guess how long it would take the computer to count to a million. Unfortunately, it took several hours.

    9. Re:My favorite algorythm by Anonymous Coward · · Score: 0

      write it again on a 2ghz pentium running windows XP, and see how long it takes a vb app to count to a million....

    10. Re:My favorite algorythm by germanbirdman · · Score: 1

      Completely offtopic, nice effect though which I always ran on my ZX Spectrum 20 years ago:

      for n=1 TO 80:CIRCLE n,n,n: NEXT n

      going ontopic again, a circle just would be too slow to draw without the BRESENHAM algorithm for slow processors.

      Mathematics are also very important. Think taylor rows (correct translation? "Taylorreihen"). Without it we wouldn't have many of the mathematical functions.

      But before you even use taylor, you need to have efficient multiplication and division algorithms for floating point numbers.

    11. Re:My favorite algorythm by Anonymous Coward · · Score: 0


      10 FOR X = 0 to 20
      20 PRINT TAB(X) "COUNTING IS 1337!!"
      30 NEXT X
      40 FOR X = 19 to 1 STEP -1
      50 PRINT TAB(X) "COUNTING IS 1337!!"
      60 NEXT X
      70 GOTO 10

    12. Re:My favorite algorythm by jezreel · · Score: 1

      Thank you for making my day :-)))))))))))))))

      --
      0 001 11 1
    13. Re:My favorite algorythm by Jagunco · · Score: 1

      Probably faster than a Sun E10000 running this [much simpler] equivalent program in java:

      class basic {
      public static void main(string args[]) {
      long x = 0;
      try {
      while (true) System.out.println(x++);
      } catch (Exception e) {
      System.out.println("An exception ocurred :)");
      }
      }
      }

    14. Re:My favorite algorythm by Anonymous Coward · · Score: 0


      Wait - even better version:

      10 X = 0
      20 Y = 1
      30 PRINT TAB(X) "COUNTING IS 1337!!"
      40 X = X + Y
      50 IF X > 19 THEN Y = -Y
      60 IF X 1 THEN Y = -Y
      70 GOTO 30

    15. Re:My favorite algorythm by Evil+Pete · · Score: 2

      Hmmmm ... speccies ...

      Wonderful little putes, especially liked the version of Basic. Easy & powerful, learn it in an afternoon. Ahhhh those were the days ... when sorting meant bubble sorts ... now there's an algorithm .. the kind of algorithm you pull out of your head because you didn't know enough to look up alternatives.

      --
      Bitter and proud of it.
    16. Re:My favorite algorythm by Anonymous Coward · · Score: 0

      Second, an algorithm, by definition, terminates...

      10 SIN
      20 GOTO HELL

    17. Re:My favorite algorythm by Anonymous Coward · · Score: 0

      while(do_i_want_to_terminate());

  13. Sounds like a poll ..... by binaryDigit · · Score: 1

    And therefore I choose:

    Cowboy Neal Bubble Butt Algorithm

  14. Oh... I can see the poll already... by Cothol · · Score: 1

    ...What is your favorite algorithm?

  15. Important Algorithms by Anonymous Coward · · Score: 1, Interesting

    Dijkstra's Single Source Shortest Path Algorithm
    Boyer-Moore Fast String Searching Algorithm

    1. Re:Important Algorithms by Anonymous Coward · · Score: 0

      would you be referring to OSPF?

    2. Re:Important Algorithms by crevette · · Score: 1

      I love Dijkstra (sp?) algo, it gets my vote too! Any algo with a complexity N is great to me.

    3. Re:Important Algorithms by Gary+Yngve · · Score: 1

      Actually Dijkstra's Algorithm is O(E log V) or O(V^2), depending on implementation. E is the number of edges and V is the number of vertices.

  16. Basic of algorithms by reflexreaction · · Score: 1, Interesting

    While I would consider myself geeky, I'm much more of a science geek than computer geek (even though I read /. on a daily basis) I have no real understanding of a computer algorithm, deep or otherwise, my search for "computer science deep algorithm" on google wasn't much help either. Could any one help the uninitiated.

    --

    We had to destroy the sig to save the sig.
    1. Re:Basic of algorithms by halo8 · · Score: 1

      Ya... like pythagorums theory, is that like an Algorithm? how about some post a quick point form crash course on Algorithms?

      THANX =)

      --
      The More Knowledge you have the Luckier you Get- J.R. Ewing
    2. Re:Basic of algorithms by nickynicky9doors · · Score: 2

      Author: David Berlinski

      Title: The Advent of the Algortihm

      Publisher: Harcourt

      --

      heuristic algorithm seeks stochastic relationship
    3. Re:Basic of algorithms by Anonymous Coward · · Score: 0

      Surely you jest?

      Most CS majors graduate without every knowing what an algorithm is.

      In my JC my first CS teacher told us to go find the definition in Knuth's book int he library, and had it on several tests throughout my series of classes with her.

      I still can't remember all 5 requirements according to Knuth, for an algorithm.

      To most people they will be things like bubble sort, quick sort, diffie-hellman....

      Just about anything you can define in a set of iterative (even if there is only 1 iteration) tasks can be construed as an algorythm.

      Ironiclly enough the only step I remember is the one I always forgot on my tests, and that is that it HAS to have a finite number of iterations, or steps. While/Repeat-Until loops still count. Conditional completion is considered finite.

      Each step has to be able to be performed and understood is another of the five, I think.

      Several sites have Knuth's definition. Just do a search on Knuth and Algorithm, and I am sure you will come across what is an algorithm.

    4. Re:Basic of algorithms by GreenPhreak · · Score: 5, Informative

      Dictionary.com defines an algorithm as:

      A step-by-step problem-solving procedure, especially an established, recursive computational procedure for solving a problem in a finite number of steps.

      Another way to think about an algorithm is this, you start out with input data in a given format, and then run some set steps on that input data until eventually it gives you output data. The nice thing about algorithms is that when they are correctly formulated, they can work without human intervention or without thinking/reasoning (just following the steps on the data). That is why they are particularly useful for computers. But they don't have to be limited to computers. Most recipes for food could be considered algorithms, that is, a set of procedures that bring you from input to output.

      A good example of a computer algorithm is one of the many sorting programs. Quicksort, bubblesort, mergesort, heapsort...these are just different algorithms for taking a list of unorganized integers and by following their steps, you get a list of integers in numerical order.

      When it comes to beauty in algorithms, people are generally referring to simplicity and efficiency in algorithms. Doing things in a way that most people wouldn't normally think to do them, yet doing them in terse and efficient ways (elegance).

      I'm not exactly sure what is meant by a 'deep' algorithm, but I would think it would reference just how complex the task that the algorithm solves is.

      My vote for best algorithms are: Sieve of Eratosthenes (an ancient greek method for finding a list of all prime numbers), and the Fast Fourier Transform, an algorithm that has revolutionized several industries.

      --
      I drink to prepare for a fight; tonight I'm very prepared. -Soda Popinksi
    5. Re:Basic of algorithms by Sangui5 · · Score: 5, Informative

      An algorithm is simply a series of steps one can take that, once you have finished them, will have solved your problem. A deep algorithm is one that is especially useful, applicable in many circumstances, and has some inate cleverness that makes it non-trivial to come up with.

      So, for example, an algorithm for searching could be:

      1. For i first item to last item
      2. If item i is what you are looking for, return it
      3. otherwise, go onto the next i.

      This isn't a very fancy algorithm, but it works, and it is useful in many many circumstances. Of course, it is also trivial to come up with (look at every item one at a time untill you find your goal), and therefore isn't deep.

      It is interesting to compare an algorithm to a heuristic. Heuristics would make great algorithms, if not for the bugs. That is, a heuristic is a set of steps you can follow that are likely to solve your problem, but aren't guarunteed. In that sense, they're just buggy algorithms.

      There are also approximation algorithms. Suppose your problem is to find the shortest route that will visit a set of cities, and return you to your starting point. This, btw, is a classic problem called the Traveling Salesman Problem, and is provably rather nasty to solve (it belongs to a class of problems called "NP-Complete"). That is, if you want the SHORTEST route, the best know method is to try all possible routes (and for even a relatively few cities, that's a lot). However, there are algorithms, that if you follow them, are guarunteed to give you an answer no worse than twice as long as the best possible. That is, we can approximate the answer, within some provable bound of optimal, with a set deterministic steps. (For the nitpickers, the approximation only works with Euclidian TSP, not general TSP, and .: doesn't give a solution to the Hamiltonian Cycle problem).

      Any other questions?

    6. Re:Basic of algorithms by leifw · · Score: 4, Informative
      (Stolen from http://www.digitale-medien.de/beckert/03_Definitio ns.htm) Donald E. Knuth gives in his book "The Art of Computer Programming" (1968) five criterias to determine if a process is algorithmic:
      1. The process must be finite
      2. Each step must be clearly defined
      3. The process may have input
      4. The process must have output
      5. The process must be effective

      To be finite, the process must end after a predictable number of steps. Each step must be unambiguous. The process may require input (parameters) to solve the problem but when complete it must return a result. The process must demonstrate effectiveness by solving the problem in a "sufficiently basic" manner.
    7. Re:Basic of algorithms by Hercynium · · Score: 4, Interesting

      What about a function that calculates sucessive digits of pi??? I'm not trying to troll here, I'm just wondering. Definitions are important things in any area of academia! As far as I know the function for calculating pi is not a finite process (unless you count each digit an a discreet process)

      A little side note: as a kid I used to crash both web servers and browsers by implementing this as a CGI script! :p

      --
      I'm done with sigs. Sigs are lame.
    8. Re:Basic of algorithms by Anonymous Coward · · Score: 0

      Calculating the digit in position X of the decimal
      expansion of pi is an algorithm. If you have a
      function that simply computes successive digits of
      pi, and never stores or returns them, then it's not
      much use, is it?

    9. Re:Basic of algorithms by Wolfier · · Score: 2

      A function that calculates all digits of PI is not an algorithm because it will never terminate.

      An "function" that never terminates, by definition, would not give you any result in finite time.

      However, if you can tell the function to return up until the 100 billionth digit, or if you specify how many digits you want, then it is an algorithm.

      A good algorithm of calculating PI just returns the text "PI", the textual representation of a series sum that sums up to PI (with "..." obviously), or a continued fraction (with "...") because a finite notation of this ratio in our current number notation system does not exist.

    10. Re:Basic of algorithms by SpryGuy · · Score: 1

      To be finite, the process must end after a predictable number of steps.

      I disagree with that definition. Can't something be both finite AND unpredictable? You know it will terminate, but you're not sure exactly when? I'm thinking of algorithms like "Find me the next prime number after X". You can't predict the exact number of steps for that one, at least in the simple implementations of that algorithm.

      --

      - Spryguy
      There are three kinds of people in this world: those that can count and those that can't
    11. Re:Basic of algorithms by Anonymous Coward · · Score: 0

      ask your mother. i showed her my 'deep algorithm' last night.

    12. Re:Basic of algorithms by Broccolist · · Score: 1

      If you just had a program that calculated the digits of pi and outputted them to the screen forever, no, that wouldn't be an algorithm. AFAIK, algorithms that don't terminate are called computational methods. But since computational methods can usually be trivially terminated at some arbitrary point (e.g. in the case of pi, stop after one million digits), their study intersects with the study of algorithms.

    13. Re:Basic of algorithms by Gary+Yngve · · Score: 1

      But in this case you can place an upper bound on the number of steps. The next prime number after p (p>2) is guaranteed to occur before p!.

    14. Re:Basic of algorithms by Anonymous Coward · · Score: 0

      "A little side note: as a kid I used to crash both web servers and browsers by implementing this as a CGI script! :p"

      Which means, you're still a kid.

    15. Re:Basic of algorithms by jcast · · Score: 1

      So you're telling me my Haskell compiler allows me to implement non-algorithms that nevertheless return a useful result?

      And, for that matter, you're saying the xinetd program running on my computer does not implement any algorithm?

      If algorithms fall so short of describing what we can actually do with computing machines, why do CS people spend so much time on them?

      --
      There are reasons why democracy does not work nearly as well as capitalism.
      -- David D. Friedman
    16. Re:Basic of algorithms by _Knots · · Score: 1

      AFAIK, there is no known formula for the n-th decimal digit of pi. However, there is one for the n-th base sixteenth (hexadecimal) digit.

      D = (1/16^n)[(1/(2n+1)) + (1/(2n+3)) + [two other similar terms]].

      I'm not sure the first two terms are right, but the formula has a (1/16^n) term multiplied by four 1/(an+b) terms, where a and b are constants and n is the n'th digit of Pi.

      -knots

      --
      Anarchy$ dd if=/dev/random of=~/.signature bs=120 count=1
    17. Re:Basic of algorithms by Phiu-x · · Score: 0

      When I was a kid there was no internet. Eh, nothing against you but your comment just made me realized how old I am haha ahhhh well, time to code again...

      --
      This is a stolen sig.
    18. Re:Basic of algorithms by Bush+Pig · · Score: 0

      I used a C implementation of Ackermann's Function (the definition of which eludes me, although I _do_ remember it was recursive) to crash a Data General unix box some years ago (the stack just grew and grew 'til it found some faulty memory). The sales engineers were quite impressed.

      --
      What a long, strange trip it's been.
    19. Re:Basic of algorithms by leifw · · Score: 1
      The Ackermann function is the simplest example of a well-defined total function which is computable but not primitive recursive. See the article "A function to end all functions" by Gunter Dötzel, Algorithm 2.4, Oct 1991, Pg 16. The function f(x) = A(x, x) grows much faster than polynomials or exponentials. The definition is:

      1. If x = 0 then A(x, y) = y + 1
      2. If y = 0 then A(x, y) = A(x-1, 1)
      3. Otherwise, A(x, y) = A(x-1, A(x, y-1))
      (stolen from http://pw1.netcom.com/~hjsmith/Ackerman/AckeWhat.h tml)
    20. Re:Basic of algorithms by leifw · · Score: 1

      Doh, should've included this before. Here's a page that has values for Ackermann's function. It grows fast. The reason that it's so hard to compute is because of the depth of recursion that it requires to solve even a low order problem.

    21. Re:Basic of algorithms by rabidcow · · Score: 1

      What's so great about the Sieve of Eratosthenes?

    22. Re:Basic of algorithms by delong · · Score: 1

      A little side note: as a kid I used to crash both web servers and browsers by implementing this as a CGI script! :p

      I would say this statement indicates you are STILL a kid. When I was a kid, computers took up whole buildings, and you handed a computer operator a stack of punch cards and breathlessly waited the next morning (if lucky) for the results of your program. You showed your age, in other words.

      :P

      Derek

    23. Re:Basic of algorithms by Anonymous Coward · · Score: 0

      And what about simulation ? An electrical network simulator such as Berkeley SPICE (based on Newton-Raphson) might fail to converge to a solution and might also fail to either fail to converge or converge, were it not for a blunt "maxiter" parameter.
      So, do ad-hoc limits to the maximum number of iterations turn a non-algorithm into an algorithm ? That would be a bit funny: Newton-Raphson by itself is not an algorithm but Newton-Raphson with a arbitrary maxiter on top becomes an algorithm.

    24. Re:Basic of algorithms by Anonymous Coward · · Score: 0

      "1.the process must be finite"

      I think I gatcha: in quantum theory energy and time are correlated by E*t=h so that if you know the first operation of your algorithm happens in a time less than t , it will at least use the energy E. Now divide the energy corresponding to the whole universe (that is finite, no ?) by E and you have the maximum number of steps in the algorithm. After that we run out of gas, sorry madam, last stop.
      Only an process that nether executes its first step could "not be" an algorithm. Thus any process is an algorithm.

      He he he ...
      >:-}
      Sorry, I just love to contradict.

    25. Re:Basic of algorithms by GreenPhreak · · Score: 1

      I just think it is impressive that an ancient Greek came up with a very elegant way of finding all prime numbers over 2k years ago. I know it doesn't rank up there as a deep algorithm, but I think it is a fundamental algorithm.

      --
      I drink to prepare for a fight; tonight I'm very prepared. -Soda Popinksi
    26. Re:Basic of algorithms by Hercynium · · Score: 2

      D'oh! Yeah, when I was about 15-16. I'm 22 now. :)

      --
      I'm done with sigs. Sigs are lame.
  17. My favorite algorithm by jwinter1 · · Score: 3, Funny

    Of course,

    Lather. Rinse. Repeat.

    --
    Anything you can do, I can do meta.
    1. Re:My favorite algorithm by seanadams.com · · Score: 5, Funny
      Lather. Rinse. Repeat.

      This fails the first requirement of an algorithm, according to Knuth:


      1 Finiteness. An algorithm must always terminate after a finite number of steps.
      - Knuth, TAOCP Vol 1, Page 4


      You know there's some guy still in the shower...
    2. Re:My favorite algorithm by blazin · · Score: 4, Funny

      I think at some point this algorithm should throw the outOfShampooException thus making it terminate after a finite number of iterations.

      Assuming everything shuts down correctly, the destructor or finalization method should be something along the lines of

      getOutofShower();
      self.dry(self);
      self.dress(s elf);

    3. Re:My favorite algorithm by Anonymous Coward · · Score: 0

      Here's version 2.0
      Lather, rinse, repeat as desired.

    4. Re:My favorite algorithm by Anonymous Coward · · Score: 0

      I think at some point this algorithm should throw the outOfShampooException thus making it terminate after a finite number of iterations.

      So, you only get out of the shower when you run out of shampoo.


      These so called "geeks" don't seem to be able to invent an algorithm that doesn't involve biting the head of a chicken. (fuck, after 2 bottles of bad Côte de Rhone I can't spell to save my life).

    5. Re:My favorite algorithm by Anonymous Coward · · Score: 0

      First socks. Then shoes.

    6. Re:My favorite algorithm by deander2 · · Score: 2

      alright, not to nit-pick a joke here, but do you really need to pass self a reference to itself? :-)

    7. Re:My favorite algorithm by LastToKnow · · Score: 1

      Well certainly. Those with youngun's frequently have to pass references to other things to dress.

    8. Re:My favorite algorithm by Syberghost · · Score: 2

      Ok. Try this one:

      :(){ :|:&};:

      I promise you that will terminate after a finite number of loops.

    9. Re:My favorite algorithm by Anonymous Coward · · Score: 0

      :(){ :|:&};:

      What the hell is that supposed to do? Doesn't look like valid C or Perl to me.

    10. Re:My favorite algorithm by Jagasian · · Score: 2

      Wait, is that always terminate on all inputs? If so, according to that criteria, a Java Virtual Machine isn't an algorithm. Nor is any universal (in the sense of Turing) programming language interpreter. Apply the diagonalization method, and its pretty obvious.

      I always thought that Kleene's partial recursive functions were a good enough description of "algorithm".

    11. Re:My favorite algorithm by Bios_Hakr · · Score: 2

      Yep, it most definately did terminate...asshole:)

      --
      I'd rather you do it wrong, than for me to have to do it at all.
    12. Re:My favorite algorithm by Mr+Z · · Score: 1

      Much too long. You want:

      $0&$0

      Does almost the same thing, only faster. If you still want the pipes, go a character longer: $0|$0&

      --Joe
    13. Re:My favorite algorithm by Fulcrum+of+Evil · · Score: 2, Informative

      It's a variant on a vorpal fork bunny. Try typing it into a bash shell on a machine you won't mind hard booting

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    14. Re:My favorite algorithm by Fulcrum+of+Evil · · Score: 1

      a Java Virtual Machine isn't an algorithm

      Well yeah, a JVM is a piece of software.

      HIBT?

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    15. Re:My favorite algorithm by dsoltesz · · Score: 1

      Actually, I've recently used this very algorithm to illustrate while loops to my niece, as follows:

      do {
      lather () ;
      rinse () ;
      } while (hairIsDirty == true)

      On the shampoo bottle, the condition is implied but nonetheless there, meeting the requirement for termination after a finite number of steps...

      btw, my niece, once a computer-phobic literary snob, has discovered the joys of qbasic: colorful blinking text, ascii art decorations, and being the only girl in class. At one time she used "geek" as an insult, but now proclaims herself a Geek Goddess. There's nothing quite like having all the boys gather 'round with jaws dropped ogling yer bodacious GUI :-D

    16. Re:My favorite algorithm by Syberghost · · Score: 2

      $0&$0

      Sure, but mine works from the shell prompt; yours requires wrapping.

      If you wanna wrap, then try this one Joey Hess gave me:

      perl -e 'fork while time'

      ...which has the added benefit of being poetry.

    17. Re:My favorite algorithm by Anonymous Coward · · Score: 0

      Ack! Throw an Exception? I miss the days when:

      if(Bottle != EMPTY)

      would suffice.

      Throwing an exception is like tearing the bottle open, throwing it at the cat, and then dunking your head in the toilet to make sure its as dirty as when you started.

    18. Re:My favorite algorithm by blazin · · Score: 1

      Like the other reply to your message, I was trying to leave it a little open ended where you could potentially have the need to dress someone else, or for someone else to dress you.

      Would you agree that it'd be important to have the ability to pass in a reference to the "undress" method?

  18. Rank alg: Anyone know the name of this one? by helixcode123 · · Score: 2, Interesting
    I don't know the actual name of this algorithm. It's quite useful if, for example, you want to match items from two lists.

    You start with 2 sets of items that are related in some way. Next, you identify possible matching relationships. You then rank each relationship pair with some metric, sort the relationship list, and remove all lower ranking relationships. This leaves you with a list of the highest ranking relationships, with items appearing only once in the relationship list.

    This was a trivial exercise in Lisp (where I first implemented it), but I've used it quite a few times in various other languages. Anyone know the name of this?

    --

    In a band? Use WheresTheGig for free.

    1. Re:Rank alg: Anyone know the name of this one? by Anonymous Coward · · Score: 0

      I believe you are referencing (at the least the start of) the Apriori algorithm for mining association rules using frequent itemsets. I think this was derived from Agrawal et al work in this area

    2. Re:Rank alg: Anyone know the name of this one? by Improper+Gesture · · Score: 1

      Yeah, I run that all the time. It's SockSort.

      while(!basket1.empty()) {
      similarity1 = 0;
      sock1 = basket.pick(1);

      sock2 = basket.pick(1);
      similarity2 = compare(sock1, sock2);
      if (similarity

    3. Re:Rank alg: Anyone know the name of this one? by Matthaeus · · Score: 1

      You didn't finish your code, but I'm hoping that you'd either implement basket as a queue or put discarded socks in a different basket if they don't match. Otherwise, you could be continually picking the same sock out of the basket to compare with a sock it doesn't match.

  19. Quick sort by Ripsnorter · · Score: 1

    My fav is the Quick Sort. Its simple, effective and something I'd like to think I'd come up with myself, but know I couldn't.

  20. Well, technically a data structure by Sangui5 · · Score: 5, Interesting

    My personal favorite is the skiplist. O(ln n) insert, search, and delete in the average case. Simple to understand, has good constant factors, doesn't require maintence (unlike trees). Really, what more could you want?

    Here's the paper:

    ftp://ftp.cs.umd.edu/pub/skipLists (many formats)
    PDF
  21. Theoretically interesting/Practically irrelevant by joe_fish · · Score: 0, Insightful
    This obsesion with algorithms is theoretically interesting but practically irrelevant. When was the last time you needed to write a sort algorithm? (And by needed I mean qsort and friends and their source were of no use.)

    In the real world 99.999% of people, smart and stupid, should use the algorythms that smart people like Knuth have invented. It would take a stupid person to think that in all but the 0.001% of cases there is any need for any more. And if you are wondering if you are in the 0.001% of cases - you're not.

    James Gosling said the same thing recently.

    The rest of the world learnt a long time ago to stop re-inventing the wheel why can't CS people learn the same lessons. Algorithms may keep your CS master happy, but they won't help you in the real world.

  22. Topological Sort by CvD · · Score: 5, Interesting

    Resolving dependencies between any number things requires this very useful graph sorting algorithm.

  23. Al-Gore-ithm by Anonymous Coward · · Score: 1, Funny

    My favorite Al-Gore-ithm was when he invented the Internet.

    1. Re:Al-Gore-ithm by Anonymous Coward · · Score: 0

      he wrote it in "LITHP"

    2. Re:Al-Gore-ithm by Anonymous Coward · · Score: 0

      And he stored it in a "Lock Box"

  24. That depends by Anonymous Coward · · Score: 0

    If by important you mean clumsy and slow, then sure! =)

  25. Algorithms? by FortKnox · · Score: 4, Interesting

    Algorithms? Its all about PATTERNS now-a-days!

    Honestly, I don't think CS will be considered "mature" just by the number of complex algorithms it has.
    There's more to CS than algorithms.

    And, I always thought algorithms were grouped into "Discrete Mathematics" not "Computer Science" (granted, there is overlap, but isn't there overlap in most sciences??).

    --
    Good quote, too many chars. Seriously, the slashdot 120 char limit sucks!
    1. Re:Algorithms? by dhogaza · · Score: 4, Funny

      Well, one world-famous mathematician was once quoted as haughtily saying that "Computer Science is just a trivial subset of Discrete Mathematics"...

    2. Re:Algorithms? by Anonymous Coward · · Score: 3, Insightful

      There is a big difference between programming and computer science.

      Patterns have more to do with programming than computer science.

      My one professor was fond of telling us everytime we showed up in class, not understanding his advanced statitistical discussions of machine states and the like:

      "Oh yes, you are programmers, not Computer Scientists."

    3. Re:Algorithms? by FortKnox · · Score: 1

      touche. Good point.

      --
      Good quote, too many chars. Seriously, the slashdot 120 char limit sucks!
    4. Re:Algorithms? by pmz · · Score: 2

      Patterns and Algoritms are apples and oranges.

      Patterns are reusable data models, whereas algorithms are reusable procedures that operate on data models. Sometimes a pattern does include an algorithm (factory objects are an example, where methods are needed to overcome the lack of multiple inheritence in a language).

      Perhaps one way of putting it is that data models capture reality, and, then, algorithms do something interesting with that reality.

      Data models and algorithms are about all there is to CS. Data models and algorithms pretty much wrap up all the other sciences and the arts, too, since that's just how humans think about things.

    5. Re:Algorithms? by wdr1 · · Score: 4, Interesting

      Er, not really.

      It depends on what field you're working in. Patterns are all the rage in OOP, and especially in Java. No doubt about that. Alas, they alone do not encompass all that is technology.

      But, more to the point, patterns are a component of software engineering. Similiar to patterns, algorithms are a component of computer science. (Although it's probably safe to to say algorithms play a *much* larger compontent in CS, than patterns are in S.E.).

      What's the difference between software engineering and computer science? Hard to explain, but it's a little bit akin to the difference between Physics and Engineering. The former tends to deal with matters more theoritcal, the latter, matters more pratical.

      It worth noting that both algorithms and patterns feed into being a good software engineer, as least IMHO.

      -Bill

      --
      SlashSig Karma: Excellent (mostly affected by moderatio
    6. Re:Algorithms? by hargettp · · Score: 1

      I respectfully disagree: it's *still* all about algorithms! And, BTW, what comes next I do not wish to aim at you personnaly. Just ignore the rest of this if I'm taking you (and me!) too seriously. ;)

      <rant>

      I've been in IT for over 10 years, and it seems so many times you find people in IT who will happily blather on about the "Visitor" pattern or another such topic (a useful pattern, to be sure), but who for the life of them can't remember any of the basic sort algorithms. It kills me; algorithms are still fundamental component of our toolkit. We can't ignore them

      </rant>

      <useful_contribution>
      Are patterns nothing more than new algorithms expressed more conceptually, with natural language instead of a programming language? Sure, a pattern does not have the same strict criteria of finite number of steps, complete in finite time, must have output, etc., but just as algorithms (and Donald Knuth's work) are guides to implementation, are patterns not also guides?

      Typically, one can express an algorithm in some form of pseudo-programming language. By choosing a programming language, we are choosing a form of expression with deep mathematical roots (think Godel, Turing, Church, etc.). What are patterns, but guides that we simply have not translated into a pseudo-language template for implementation? The Visitor pattern is a great example: one can express the pattern in a number of languages, quite simply.

      So, perhaps we incorrectly differentiate between patterns and algorithms based purely on the language of expression. Perhaps instead we should look for that new language, or expand an old programming language, that can capture the ideas of patterns more precisely and inline in the same code as those code artifacts we have traditionally called algorithms.

      And with the expressive power of this new language, what would programming be like?
      </useful_contribution>

    7. Re:Algorithms? by t · · Score: 1
      Yes yes yes. They should also put on every exam, "What is the definition of a scientist." I have feeling most people would fail. Especially those who insist it should be implemented in Java.

      t.

    8. Re:Algorithms? by russellh · · Score: 1
      Patterns have more to do with programming than computer science.

      You're right, but not in the way you think you are. You're thinking of the software industry popularization of Alexander's patterns, which is of course all about programming and not computer science. However, they have dumbed down the concept significantly. If you read Alexander's A Pattern Language, and compare it with the gang of four book, there's just no comparison - Alexander's is deep, probing, and almost alive; the GoF's book is shallow and dead. The comparison between patterns and computer science is like biology to physics: biology is about life, whereas physics is about the structure of matter. We have a new field here - nobody's recognized it yet.

      --
      must... stay... awake...
    9. Re:Algorithms? by jcast · · Score: 0, Flamebait

      You mean the solvable subset?

      --
      There are reasons why democracy does not work nearly as well as capitalism.
      -- David D. Friedman
    10. Re:Algorithms? by pkiguruman · · Score: 1

      hmmmm....I thought that it's all ball bearings nowadays.

    11. Re:Algorithms? by FortKnox · · Score: 1

      ROFL!!

      I think it was the bypass line....

      What's your name?
      Fletch
      Your FULL Name?
      Fletch F Fletch
      Occupation?
      I'm a shepard...

      --
      Good quote, too many chars. Seriously, the slashdot 120 char limit sucks!
    12. Re:Algorithms? by Rob+Riggs · · Score: 1
      I've been in IT for over 10 years, and it seems so many times you find people in IT who will happily blather on about the "Visitor" pattern or another such topic (a useful pattern, to be sure), but who for the life of them can't remember any of the basic sort algorithms. It kills me; algorithms are still fundamental component of our toolkit. We can't ignore them
      Oh horsepucky! It's important to know these things if one is writing libraries. Application programmers have little need for this knowledge. Their tools should provide it for them. You don't need to be a scientist to build a car (or even an automobile engine) these days. Software engineering has long since advanced past the point that one need be a computer scientist to write computer applications.

      --
      the growth in cynicism and rebellion has not been without cause
    13. Re:Algorithms? by jcast · · Score: 1

      I should probably mention that, according to the Curry-Howard isomorphism, Computer Science (actually that subset of CS that studies algorithms) and (constructive) proof theory are interchangeable.

      --
      There are reasons why democracy does not work nearly as well as capitalism.
      -- David D. Friedman
    14. Re:Algorithms? by sawanv · · Score: 1

      I am inclined to agree with your prog. Most of us are really programmers not computer scientists.

  26. Recursion? by gatekeep · · Score: 1

    I'm not sure if it'd be an 'algorithm' per se, but I've always found the concept of recursion/mathematic induction to be extremely useful. I don't know how much use it is to true programmers, but for writing useful shell scripts and administrative tools it's something I rely on quite a bit.

  27. Boyer-Moore String Searching by Foresto · · Score: 5, Informative

    I dont think I'd call it my favorite algorithm, but the Boyer-Moore string searching algorithm is pretty cool.

    1. Re:Boyer-Moore String Searching by IvyMike · · Score: 4, Informative

      For some reason, I like string searching algorithms too. Check out this monster list of thirty or so different exact string searching algorithms, complete with description, code, and an interactive java demo for each one.

      I never thought I'd spend hours typing "baaabbabbabc" into a java applet until I found that page. :) Educational and cool.

  28. Off the top of my head by td · · Score: 5, Insightful

    Quicksort
    The Unification Algorithm
    Skip Lists
    Conjugate Gradients
    Karmarkar's linear programming algorithm
    Knuth-Morris-Pratt string matching
    Multidimensional scaling
    The Kernighan-Lin TSP & graph-partitioning methods
    Lempel-Ziv compression
    Fast Fourier Transform
    Quine-McCluskey optimization
    Celine/Gosper/Zeilberger/Wilf algorithm for hypergeometric identities
    Fast Multipole method

    --
    -Tom Duff
    1. Re:Off the top of my head by kippy · · Score: 1

      Skip list are a data structure, not an algorithm.

      FFT, right on.

      My favorates are:

      huffman coding
      heap sort
      merge sort

    2. Re:Off the top of my head by Anonymous Coward · · Score: 0

      The list sounds like spells from the game Baldur's Gate.

    3. Re:Off the top of my head by cpeterso · · Score: 3, Funny


      I like bubble sort.

    4. Re:Off the top of my head by jasha · · Score: 1

      How about bogo-sort? I especially like the variant where "... Implementation of step 2 is left as an exercise for the reader"

    5. Re:Off the top of my head by Sangui5 · · Score: 1

      Ah, the skiplist. Every time algorithms come up, the skiplist is not paid nearly enough attention.

      I know that I've posted this URL once to this article aready, but skiplists are practically ignored, compared to how nifty they are. No balanced tree has a right to exist (except perhaps B-trees because the mesh nice with hardware) with skiplists around:

      ftp://ftp.cs.umd.edu/pub/skipLists/skiplists.pdf

      And I'd like to add 2 more nifty and somewhat ignored algorithms: the Burrows-Wheeler Transform and the Discreet Cosine Transform. Burrows-Wheeler is what gives us bzip, and Discreet Cosine is what gives us JPEG and MPEG. Heck, while I'm on a compression kick, lets add MTF (move-to-front) and Huffman Codes.

    6. Re:Off the top of my head by discstickers · · Score: 1

      Hurray for Lemepel-Ziz! The decompression is simply beautiful, especially compared to the hell that is compression. I stared at my decompress for well over six hours, and I never got it quite right working with a trie. When I switched to an array of Strings, it took five minutes. Like I said, beautiful. =)

      --
      I have a shitty sig!
    7. Re:Off the top of my head by cpeterso · · Score: 2


      One problem with skip lists is that each node must be dynamically resizable because the number of forward pointers is changing and not known at compile-time.

    8. Re:Off the top of my head by cpeterso · · Score: 2


      oh yeah, another problem with skip lists is that they are not very friendly to multiple readers and writers because the nodes provide unfortunate concurrency "chokepoints". In a binary tree, for example, subtrees can be locked without blocking readers in adjacent subtrees.

    9. Re:Off the top of my head by blazin · · Score: 2

      I taught a C++ data structures course and used bogo-sort on a test to see if the students understood O() notation. I explained what it was based on using real word example of playing 52 card pickup until the cards were sorted, then left them to figure out if it would have a good runtime or not.

    10. Re:Off the top of my head by marcelk · · Score: 1


      I think you missed creative loop unrolling.

    11. Re:Off the top of my head by Woodie · · Score: 1

      I'd add the following, if they can be considered algorithms:

      Genetic Algorithms/Programming
      Neural Networks
      Fuzzy Logic

      While these may appear focused on AI - they have had real application in a lot of areas.

    12. Re:Off the top of my head by Pseudonym · · Score: 2

      It's an interesting definitional problem as to what counts as "deep". My intuition (which may of course be faulty) suggests that a "deeper" algorithm is one that can be either used widely or extended to other areas. This would make merge sort "deeper" than quick sort and DMC or PPM "deeper" than L-Z compression.

      Some more suggestions:

      • A* search.
      • The simplex method.
      • Aho's DFA state minimisation algorithm.
      • Risch integration.
      • Dijkstra's shortest path algorithm.
      • The "Graham scan" convex hull algorithm.
      • Deterministic linear-time selection.
      • Monte Carlo simulation. (Obligatory comment on patents held by td's employers deleted.)
      • Pretty much anything by Robert Tarjan.
      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    13. Re:Off the top of my head by Accelerated+Joe · · Score: 1

      Knuth-Morris-Pratt string matching

      The KMP algorithm is the only algorithm I've ever seen that shocked me when I first saw it. It is so simple, and yet I probably never would have thought it up on my own. It's just beautiful!

      --
      They who would give up an essential liberty for temporary security, deserve neither liberty or security
    14. Re:Off the top of my head by Anonymous Coward · · Score: 0
      Others have hit the top ones. Here are some of my other favorites:
      • Minimax
      • DES (a lot of work went into those S-boxes)
      • Sorting networks (see Knuth's Sorting and Searching)

      There's also a lot going on in Computational Linguistics, especially in the areas of part-of-speech tagging, content extraction, and synonym detection.

      --Pat / zippy@cs.brandeis.edu

    15. Re:Off the top of my head by spencerogden · · Score: 2

      From a quick perusal of the paper it would seem that a max number of forward pointers is set, and that each node could have this number. It would seem that an array of say ten points would not be that bad.

    16. Re:Off the top of my head by Anonymous Coward · · Score: 0

      Off the top of your head my ass.

      Anybody can read an algorithms book and pull out some names. Throwing LZ, quicksort, and skip lists in there proves you're not paying attention and making shit up.

    17. Re:Off the top of my head by Anonymous Coward · · Score: 0

      If you're curious to know who discovered the Quicksort algorithm, go to http://research.microsoft.com/~thoare/

    18. Re:Off the top of my head by Anonymous Coward · · Score: 0

      Then can I add C++, if that can be considered an algorithm?

    19. Re:Off the top of my head by powderfinger · · Score: 1

      Is it really! that ! Tom Duff.
      I think we should be told.

  29. Diffie-Hellman, too by paulschreiber · · Score: 5, Interesting
    Don't forget Diffie-Hellman key exchange, RSA's lesser-known partner in crime.

    Paul

    1. Re:Diffie-Hellman, too by 3am · · Score: 1

      That's not really an algorithm...

      --

      A: None. The Universe spins the bulb, and the Zen master merely stays out of the way.
    2. Re:Diffie-Hellman, too by Grit · · Score: 1

      Hmph! Just because us distributed computation people have to count messages in addition to everything else doesn't mean it's not an algorithm!

      I admit the line between algorithm and protocol is fuzzy at best. It's say that Diffie-Hellman is an algorithm, but a specific use of it is a protocol. Just like BGP (the Internet routing protocol) is a (distributed) implementation of the Bellman-Ford algorithm.

    3. Re:Diffie-Hellman, too by 3am · · Score: 1

      I'll buy that - I think it's just the mathematician in me is much more comforted by the words 'instance of an algorithm' or 'implementation of an algorithm' in this case.

      --

      A: None. The Universe spins the bulb, and the Zen master merely stays out of the way.
  30. Maybe you should read the interview again by Pussy+Is+Money · · Score: 1

    In the interview, Knuth also repeatedly remarks on the importance of the "individual bricks" over "milestones" and top-ten lists. So maybe you should read the interview again.

    --
    Pushin' 'n dealin', shovin' 'n stealin'
  31. An important algorithm I use everyday... by gpinzone · · Score: 5, Funny

    begin
    while alarm ringing
    cover head with blankets
    mprecate the onerous noisemaker softly
    consider turning the damn thing off
    if feeling remarkably hyperactive
    then
    lethargically slither out of blankets
    sinuously stretch out arm
    sigh
    bang it to kingdom come
    else
    go back to sleep sweet sleep
    endif
    if hear name being called
    then
    see who it is
    if kid brother/sister
    then
    ready
    aim
    fire
    watch baneful clock execute a parabolic trajectory
    in approximate direction of youngster
    if target intercepted
    then
    ignore howls for Amnesty International
    else
    swear a thousand maledictions
    endif
    else if father
    then
    get out of bed hyper-quickly
    if feeling watched
    then
    turn alarm off gently
    else
    kick alarm off gently
    endif
    else if mother
    then
    scan her for arms, especially those prohibited by
    Geneva Convention
    if result is affirmative
    then
    begin negotiations
    else
    pretend not to have seen her
    increase snoring intensity
    endif
    endif
    if feel something cold and wet being sloshed onto
    blankets
    then
    yell blue murder
    get out
    endif
    endwhile
    end

    Dinoj Surendran @ 1995 - no rights reserved

    1. Re:An important algorithm I use everyday... by Anonymous Coward · · Score: 0

      suggest one algorithm change:

      else if (mother) then
      if (!dadpresent && skantily_clad) then
      sneak_a_peak()
      else if (friends_mom) then
      try_a_feel_anyway()

    2. Re:An important algorithm I use everyday... by Requiem · · Score: 1

      Yes, yes, but what is the time complexity?

    3. Re:An important algorithm I use everyday... by AutumnLeaf · · Score: 1

      Shouldn't that middle bit be:

      ready, fire, aim? I know that's my mode of operation when the alarm is going off...

    4. Re:An important algorithm I use everyday... by Anonymous Coward · · Score: 0

      He also forgot the grazhny malenky odin rookered lubbilubbing veshch that nadsat malchicks do so horrorshow, with their neezhnies round their nogas.

  32. Hello World by Wolfier · · Score: 4, Interesting

    One of the most important algorithms ever invented.

    Seriously, how about Simulated Annealing or Genetic Algorithm?

    1. Re:Hello World by Anonymous Coward · · Score: 0

      Hello World is not an algorithm from a functional point of view -- it relies 100% on side-effects and does not return a value.

    2. Re:Hello World by Anonymous Coward · · Score: 0

      It does if you consider it a transformation of the input environment ot an output environment. E.g. if you use a typewriter-style teletype, the input is the page with whatever's printed on it, the output is the page with whatever was printed on it plus "Hello World."

    3. Re:Hello World by rlotun · · Score: 1

      Yes, lest we forget the biologically inspired algorithms in areas such as:

      1) Evolutionary Computing: Genetic Algorithms, etc.
      2) Function of the brain: Neural Networks (more specifically, backpropogation)
      3) Machine Learning

      --
      "This statement is false."
  33. Fast routing agorithm by zero2k · · Score: 2

    Ok, since we're all stuck on the Internet, which is something that has to grow in size continually, I'd say one the routing algorithm has got to be one of the most important. The Internet can't exist without it. Also to note is that we do need faster routing algorithms to cater for future addressing.

    1. Re:Fast routing agorithm by Anonymous Coward · · Score: 0

      Umm... which routing algorithm are you refering to? rip? bgp? OSPF? Cowboy Neal's Man-in-the-middle routing algorithm (CNMITMRA)?

  34. simplex method by Gary+Yngve · · Score: 5, Interesting

    It is so far-reaching.

    linear programming, minimax game searches, network flow, primal-dual techniques for approximation algorithms......

    1. Re:simplex method by mindriot · · Score: 2

      Actually, if you say minimax, I'll have to say I prefer alpha-beta pruning...

    2. Re:simplex method by mike_g · · Score: 1

      I took a linear programming class a while back, and the professor stated that more computing time has been spent running the simplex method than any other algorithm in history. Definitely an important one, but my favorite is still the FFT.

  35. Three favorite algorithms by Anonymous Coward · · Score: 2, Insightful

    * Randomized primality testing
    * Gaussian elimination
    * Euclid's gcd algorithm

    All three run in time polynomial in the bitlength of the input, yet the first thing that springs to mind is exponential time:

    primality testing: try dividing by every number between 2 and sqrt(N).
    matrix determinant: the straight definition has n! terms. With Gaussian elimination you can compute the determinant in O(n^3) time.
    gcd: factorize both number and compare? (ugh)

    Gotta appreciate algorithms that show real insight into a problem.

    1. Re:Three favorite algorithms by Anonymous Coward · · Score: 0

      Randomized primality testing This doesn't tell you anything besides the fact that you have a (1/4)^n possibility that you have a false positive.
      Gaussian elimination This does not do a damn thing for the matrix permanent (Knuth 4.6.something or rather)
      Euclid's gcd algorithm It's OLD

  36. bogosort by paulschreiber · · Score: 2
    you can't forget bogosort. :-)

    Paul

    1. Re:bogosort by Anonymous Coward · · Score: 0

      Or how about the algorithms behind the ever-important strfry and the ubiquitous memfrob?

    2. Re:bogosort by Anonymous Coward · · Score: 0

      Come on!!! Bogosort supposedly built the universe. How can it not be considered important?

    3. Re:bogosort by Anonymous Coward · · Score: 0

      I assume that either the O(n) version has never been implemented, or we are very, very, very lucky.

  37. Very Deep Algorithm by stinkydog · · Score: 1, Troll

    dim accounttotal 'Total number of accounts
    dim myaccount 'my account

    for count=1 to accountotal
    myaccount=myaccount+(100*account(coun t)-100*int(ac count(count)))/100
    account(count)=int(account(cou nt)*100)/100
    next

    Run once a week for a healthy balance
    SD

    --
    âoeWho knew something as harmless as willful ignorance could end up having real consequences?â
    1. Re:Very Deep Algorithm by DiS[EnDeR] · · Score: 1

      Yummy, VB....
      "waiter, my programming language is not verbose, send it back"

      --

      Harder.. Better.. Faster.. Stronger
    2. Re:Very Deep Algorithm by Anonymous Coward · · Score: 0

      Stinkydog, you forgot to redim preserve account(count), come on what are you thinking. Or better yet how about this algorithm stinkydog = moron.

  38. Favorite algorithms by gewalker · · Score: 2, Interesting

    Hashing algorithms. Stick that in your pipe and smoke it.

    On basis of frequency, it's obvious that simple algorithms are the most common. Linear search of an array, bubble sorts (no matter how bad they are), and linked lists are so common that its hard to believe that anything could be more popular (or frequently abused)

    1. Re:Favorite algorithms by PD · · Score: 2

      Hashes are just so useful. If I were among the group of people working on the C++ Standard Template Library I'd have stuck hashing containers in. Right now, things like hash_map are not a part of the official standard, BUT there are some good implementations out there. Supposedly, hashing containers are going to be in the next standard - hooray!

    2. Re:Favorite algorithms by Anonymous Coward · · Score: 0

      hehe... "hashing"... stick that in your pipe and smoke it
      i love it

  39. How about CSS? by JonWan · · Score: 4, Funny

    The "Content Scrambling System" it seems pretty Damn important to the MPAA and Congress. They even passed a law (DMCA) to support it..

  40. Euler's Totient Theorem by alanw · · Score: 1

    Elegant, deep, and the foundation of public
    key cryptography.

  41. The best by Snuffleupagus · · Score: 1

    I personally have a love hate relationship with B+ trees.

  42. discrete fast fourier transform by Gary+Yngve · · Score: 2

    Anything from Photoshop to cellphones benefits from fast signal processing. A little complex analysis turns an O(n^2) algorithm to O(n log n).

    1. Re:discrete fast fourier transform by Anonymous Coward · · Score: 0

      Cell phone use STAP(Space Time Adaptation Protocol) algorithms, not FFTs, at least with the current GSM systems.

  43. Fibinacci Number Algorithm.... Very fun by taya0001 · · Score: 1, Interesting

    int fib(n)
    {
    if(n==0|| n==1)
    return n;
    else
    return fib(n-1)+fib(n-2);
    }

    in this you will find the meaning of life

    1. Re:Fibinacci Number Algorithm.... Very fun by getch(); · · Score: 1

      Ah, yes. The above implementation is the textbook example of situations in which one shouldn't use recursion.

    2. Re:Fibinacci Number Algorithm.... Very fun by RazorJ_2000 · · Score: 1

      That IS the meaning of life: "don't use recursion". Pretty deep, eh.


      --
      pi=sigma{n:0-infinity}[(1/16)^n][(4/(8n+1))-(2/(8n +4))-(1/ (8n+5))-(1/(8n+6))]
    3. Re:Fibinacci Number Algorithm.... Very fun by GMontag451 · · Score: 2

      Here's a much faster algorithim: gr = (sqrt(5) + 1) / 2; grp = (gr - 1) * -1; int fib(n) { return (gr^(n+1) - grp^(n+1))/(gr-grp); }

    4. Re:Fibinacci Number Algorithm.... Very fun by Anonymous Coward · · Score: 0

      And here is the reason why one should very definitely use recursion:

      F(0) = 0; F(1) = 1; F(2) = 1;

      F(n) = (n odd) ? F((n + 1)/2)^2 + F((n - 1)/2)^2 :
      F(n/2 + 1)^2 - F(n/2 - 1)^2 ;

      This is really fast, and even faster if you can store and reuse intermediate results.

      F(100000) iterative: 45 secs.
      F(100000) recursive: 15 secs
      F(100000) saving intermediate results: < 1 sec

      (Results with Maple 6 on a PIII-650.)

  44. Bubblesort till I die mofo by Anonymous Coward · · Score: 0

    I use it every day to sort all my bitchez.

  45. Fast Fourier Transform by sketchy_gomez · · Score: 5, Interesting

    I'm going with the Fast Fourier Transform, because it is ubiquitous in signal processing and it has various number theoretic applications. As an added bonus: The Quantum Fourier Transform can be used in Shor's Algorithm to factor numbers in polynomial time! Although, this is not yet practically realizable..

    --

    Chaos is a name for any order that produces confusion in our minds. --George Santayana
  46. Shallow algorithms by csbruce · · Score: 2, Funny

    1) Patent the obvious
    2) Sue
    3) PROFIT!!

  47. Use this one everyday by ill_conditioned · · Score: 1

    I'm a big fan of the Ostrich Algorithm...

    1. Re:Use this one everyday by Matthaeus · · Score: 1

      I remember the first time I heard about the Ostrich Algorithm. I was taking an OS class from a short little feisty Vietnamese guy, and the Ostrich Algorithm was actually on the syllabus and the tests as being the best way to avoid resource deadlock. Then again, that was for a Software Engineering degree. Now that I'm in Computer Science (and have to take OS all over again), I fully expect to have to deal with resource deadlock in its entirety.

  48. Re:Been a while since I've done this by Anonymous Coward · · Score: 0

    You always have to lick scrotum hairs don't you silly

  49. AVL Trees by Anonymous Coward · · Score: 0

    In my study of data structures and algorithms, the AVL algorithm is by far my favorite. What a beautifully simple algorithm, with such good implications (balanced binary search trees).

    I would say that RSA is a close runner up, as far as the algorithms that I've studied.

  50. Fast Fourier Transform by Anonymous Coward · · Score: 0

    I still don't understand exactly how it works, but it's completely neccesary for advanced digital audio effects and synthesis.

  51. confusing theory with engineering? by Anonymous Coward · · Score: 2, Insightful

    IMHO, asking "what are the outstanding problems for which algorithms would be immediately placed in the "Top 1000" category?" reveals a misunderstanding of Knuth's article (All Questions Answered). In regards to "deep algorithms", Knuth was speaking of the maturity of computer science as a theoretical discipline, not as an engineering science. An algorithm is "deep" because it is beautiful (to use another of Knuths words), that is, it demonstrates a penetrating insight into the nature of computation. In this regard, the actual problem domain addressed by any given algorithm, in and of itself, is irrelevant. In fact, in the same article, Knuth is asked to give the five most important problems in computer science. He replies that he "doesn't like this top ten business", but prefers the "bottom ten". What is important, he says, is "the little things ... the stones in the wall".

  52. The CORDIC Algorithm by Caractacus+Potts · · Score: 4, Informative


    COordinate Rotation DIgital Computer

    This algorithm is implemented by most FPUs and even some PGAs to calculate trigonometric and hyperbolic functions. It replaces the evaluation of those power series you've already forgotten about from school with a clever combinations of bit-shifts and additions. Back in the days when multiplications were much more expensive than additions, this is how it was done.

    1. Re:The CORDIC Algorithm by Anonymous Coward · · Score: 0

      CORDIC isn't an algorithm per se, but a bunch of numerical methods.

      Saying CORDIC is an algorithm is like saying Newton's method or Gauss elimination are algorithms.

    2. Re:The CORDIC Algorithm by Anonymous Coward · · Score: 0

      I've never come across this before, so I thought I'd do a big of googling. Funnily, a search for CORDIC on Google lists it under the "Recreation > Humor > Bizarre > Dancing Pages" directory. Hmmm

  53. Re:Theoretically interesting/Practically irrelevan by Anonymous Coward · · Score: 2, Insightful

    First off, it's clear that you have a very narrow view of what is actually done with computer science. Granted a lot of what the casual or application programmer deals with can seldom involve the creation of a new algorithm. However, the field of algorithms is constantly expanding.

    Examples would be:
    A guidance system
    Any artificial intelligence
    Image manipulation
    Video games (quake engines!?!?!)
    Telecommunications routing software
    VLSI Design
    etc..

    As far as I know, that stuff is pretty important in the real world. Yes, algorithms exist to do pretty much all of those (in fact, with brute force, many are trivial). However, we are constantly looking for "better" algorithms. If new algorithms are not relevant, why would companies, like Intel, pay hundreds of millions of dollars for a program that would optimally lay out the elements on their chips for them?

  54. The pr0n algorithm by NanoGator · · Score: 2

    I have no idea how it works, but search engines have no trouble finding me pics of nekkid wimmenz. Kudos to whoever invented it!

    --
    "Derp de derp."
  55. Prune your betas! by Logician007 · · Score: 5, Interesting

    Alpha-Beta Pruning or "minimax" is my favorite. It is a good way to trim your search space, but as far as I know pretty much is only used in strategy game playing. Chess specifically. The hard part about it is comming quantifying the value of the moves each player can make (Number of pieces, position on the board, tactics, blah!). Unlike most tradeoffs in CS, this one saves both time & space.

    1. Re:Prune your betas! by debrain · · Score: 2

      It also has useful applications in pruning the SAT search space.

    2. Re:Prune your betas! by Anonymous Coward · · Score: 0

      Agree, but , AFAIK, actually derivative algorithms are used
      nowadays, like NegaScout.... Most of applicaitons of alpha-beta are
      not plain vanilla, either -- they use things like various aspiration
      windows, null moves and tranposition tables (often combined with
      iterative deppending, for a nice and fast ordering heuristic) to
      cull more efficiently..

      MTD-f is a cool new algorithm using memoiizing alpha-beta
      with null windows to binary-search the value of the solution.

    3. Re:Prune your betas! by SplendidIsolatn · · Score: 2, Informative

      The only problem with A/B (and I love it and have implemented it a number of times in games) is that it only works for abstract strategy games with a zero-sum score. (meaning, one player is winning by the exact same amount the other player is losing...thus, zero sum) So chess, backgammon, checkers, hex, and any other game with a zero-sum board evalution it'll do fine. Otherwise it won't work very well.

      Plus, an A/B search is only as good as the method you are using to evaluate the game. I'll use minmax and a good heuristic rather than A/B with a bad one. Just some food for thought.

      --
      sig--we don't need no goddamn sig
    4. Re:Prune your betas! by Anonymous Coward · · Score: 0

      Surely this is a hueristic not an algorithm

    5. Re:Prune your betas! by gregbaker · · Score: 2
      Alpha-Beta pruning is "deep"? Isn't "If you did this and the outcome is be horrible, don't do that; if it would be really good, do it" not a more-or-less complete summary of it? This is the thinking that leads to software patents.


      And, as another post mentioned, it's a heuristic, not an algorithm.

    6. Re:Prune your betas! by gregbaker · · Score: 1

      "is be horrible" isn't be what I meant.

  56. DeCSS by mikeee · · Score: 2

    Clearly, the most important algorythm. ;)

    1. Re:DeCSS by iceburn · · Score: 1

      Oh yeah, that thing that takes cascading style sheets out of web pages. I think I have a copy of it on my drive. Very useful.

      --
      A sphincter says what?
    2. Re:DeCSS by Anonymous Coward · · Score: 0

      You, I hope, are not really that stupid.

      Are you?

    3. Re:DeCSS by Anonymous Coward · · Score: 0

      http://www.pigdog.org/decss/ checkit foo

  57. Blatant pro-Israel hypocrisy by Anonymous Coward · · Score: 0
    I am quite sick of the blatant conservatism, anti-Catholicism (I am Protestant myself!) and pro-Israel bias of The Drudge Report. Fucking NY slime.

    Sharon should be dragged to the Hague and made a cell-mate to Milosevic! Fucking war criminal.

  58. Re:Theoretically interesting/Practically irrelevan by Anonymous Coward · · Score: 0

    not to pick nits but: Telecom routing software are realy protocol stacks, that in turn are constructed from many algorithms.

  59. There are always new problems by Anonymous Coward · · Score: 1, Insightful

    'Companions the Creator seeks, not corpses, not herds and believers. Fellow creators the Creator seeks, those who write new values on new tablets. Companions the Creator seeks, and fellow harvesters, for everything about him is ripe for the harvest.'

    (Friedrich Nietzche)

  60. Re:Theoretically interesting/Practically irrelevan by Anonymous Coward · · Score: 0

    Yes. There seems to be a masochistic strain of programmers who's first reaction is to re-implement/re-invent in response to any problem. They are a strange sort; their impulses run directly contrary to the hacker ethos and they tend not to be particularly productive. I'm on a project now with one and I find myself in the uncomfortable position of having to defend suggestions like: There's an OSS package that does that.

    he: We could write our own parser.
    me: Dude, we've got enough to do without rewriting this. We just need to stick to these interfaces.
    he: Then we won't have control.
    me: We don't need that level of control.
    he: You're taking the science out of computer science.

    Well pal, you're taking the production out of production software.

  61. Algorithm to understand what's an algorithm. by locoluis · · Score: 1
    1. For all the comments on this article.
    2. See which ones show a list of actions to do, especially those who specify conditions (if/then/else), or control flow (repeat,for each,while,until...)
    3. Study the selected examples.
    4. Reload and repeat until understood.
    I *so* have a future in CS teaching.
    1. Re:Algorithm to understand what's an algorithm. by nickynicky9doors · · Score: 2

      I'm not trolling, but wouldn't your injunction: 'until understood', fail as a step in an anlgorithm?

      --

      heuristic algorithm seeks stochastic relationship
    2. Re:Algorithm to understand what's an algorithm. by Anonymous Coward · · Score: 0

      Should be:

      1. For each ( the comments on this article )
      2. if(shows a list of actions to do, especially those who specify conditions || control flow )
      3. Study ( the selected examples )
      4. Reload
      5. repeat until (understood!=false)

  62. Hash tables and sort algorithms by igrek · · Score: 2

    Perhaps, hash tables and quicksort are the top software algorithms. They both are usually hidden from programmers (unless you're coding in low-level programming language), so we don't always $pay->{$attention} to the details.

    Just think about it, how many times the hash tables and sort algorithms were used to render this very page?

  63. What is your favorite algorithm? by Conspiracy_Of_Doves · · Score: 1

    Ok, this is one for everybody who as ever posted the phrase "Is this really news for nerds?"
    .
    .
    Give me a nice recursive function any day. :)

  64. My favorite by SGDarkKnight · · Score: 1

    Experienced COMPUTER PROGRAMMERS modify Algorithm A by placing a known elephant in Cairo to ensure that the algorithm will terminate.

    Assembly language programmers prefer to execute Algorithm on their hands and knees.

    --

    ...A no smoking section in a restaurant is like having a no peeing section in a swimming pool...
  65. van Jacobson's congestion avoidance and control by Subcarrier · · Score: 2, Interesting

    Without it Slashdot would not exist.

    --
    "I have opinions of my own, strong opinions, but I don't always agree with them." -- George H. W. Bush
  66. But smart people won't ignore the topic... by Da+VinMan · · Score: 4, Insightful

    It's well and fine to say that we should use the algorithms "that smart people like Knuth have invented", but that's not enough if you're going to make your living as a genuine developer. I agree that we should use the frameworks we are provided in order to get the highest productivity, but if you can't take some pleasure in the construction of an elegant piece of code (algorithmic or otherwise), then you're just a technician who can easily be replaced when the next fad rolls out.

    You can put people like Knuth on a pedestal if you like, and that is certainly warranted in his case. But real progress will only be realized when you disregard people like him and do something of your own.

    --
    Please mod this post only if you think others should/n't read this. I have enough ego^H^H^Hkarma. Thanks!
    1. Re:But smart people won't ignore the topic... by jgerman · · Score: 4, Insightful

      That's ridiculous, you don't disregard them, you build on their work just like every other science, you stand on the shoulders of giants, maybe you become a giant for the next generation, but real progress is NEVER made when you disregard what came before you.

      --
      I'm the big fish in the big pond bitch.
    2. Re:But smart people won't ignore the topic... by sdowney · · Score: 1
      How in hell did this idiot get modded up to insightful.

      I can only hope that he's not employed by anyone who cares about the quality of the work done for them.

      Apparently he'd prefer to waste their money reimplementing linked lists, mostly likely incorrectly.

      The best developers steal shamelessly from people like Knuth, Sedgewick and Hoare. There's no need to reinvent bicycle wheels, especially when there are high performance race car wheels free for the taking.

      Besides, the fundementals are HARD. There are thousands of ways of screwing up a linked list implementation. Most of them subtle. And that's supposed to be an easy one. String matching, hash tables, red-black trees, quicksort, etc, are even subtler.

      Implementing them in college, in a CS course, is so you gain a deeper understanding of how they work. It's not so that you go out and reinvent them whenever you need one.

    3. Re:But smart people won't ignore the topic... by t · · Score: 1
      Unfortunately, sometimes progress in the "correct" direction can only be made when you disregard what came before you. e.g., the Earth is the center of the universe.

      Personally I feel that string theory is an obstacle to progress.

      And probability based speech recognition algorithms have to get thrown the fuck out. It's a dead-end method.

      t.

    4. Re:But smart people won't ignore the topic... by jgerman · · Score: 2

      Fair enough, perhaps we are differing on the term disregard. I took your use of it to mean more of an ignore, while I feel that even the mistakes of the past need to be used to further technology in the future.

      --
      I'm the big fish in the big pond bitch.
    5. Re:But smart people won't ignore the topic... by Da+VinMan · · Score: 2

      Apparently, you missed the "I agree that we should use the frameworks we are provided in order to get the highest productivity" part of my statement.

      I'm not an idiot. In fact, my customers do depend on me for high quality and highly maintainable solutions. I'm pretty good at making my customers happy too.

      Besides all that though, I agree with you, especially on the fact that the fundamentals are hard. The fundamentals keep getting harder too as folks find more and more ways in which to apply those implementations. Think about the linked list example. Now think about the linked list example in a multi-threaded situation. Now think about the linked list example in a multi-threaded *and* garbage collected situation. All of those are very different problems which add permutations of complications onto a very basic idea; the implementation of which becomes more complicated with each new dimension of functionality.

      BTW - You could relax your finger a bit on that flamethrower. You're coming across as an over-reactive moron yourself since you don't appear to have read my whole post. I doubt that you are in fact an idiot, so why not put your best foot forward?

      --
      Please mod this post only if you think others should/n't read this. I have enough ego^H^H^Hkarma. Thanks!
    6. Re:But smart people won't ignore the topic... by jovhl · · Score: 1

      but real progress is NEVER made when you disregard what came before you

      Never is a strong word. Fresnel tried, and succeded, in formulating a correct theory of diffraction precisely because he didn't know all that had been done before him.
      As it was, Fresnel provided conclusive proof that Newtons view of light as particles was incorrect, and that diffraction was a direct result of the wavelike properties of light. Huygens, a contemporary of Newton, held a similar view, but was considered a quack by most since his theory went against Newtons. Fresnel proved Huygens had the right idea all along, but he didn't know that when he did his experiments and formulated his theory. If he had, he wouldn't have "wasted" all that time making his own experiments and theories. Maybe he still would have cracked the problem, but most probably he wouldn't. Many had tried to stand on the shoulders of Newton and Huygens, but that didn't help them solve the problem.

  67. Algorithm Classes by Anonymous Coward · · Score: 0

    Not sure about particular algorithms, but classes of algorithms such as greedy, flow, and linear programming would what I (however vague "I" is, in this case) consider fundamental, simple, elegant, and important.

    However, any algorithm developed to solve NP-complete problems in polynomial time would easily be considered as the most important algorithm. Not only would it allow us to solve NP-complete problems in polynomial time (duh), it would also prove that P = NP, one of the fundamental problems in classification in the study of algorithms in computer science. Of course, if one was to come up with an algorithm to P-Space or Halting problem (however unlikely)...that's a whole different story.

  68. Game playing algo... by KaiserSoze · · Score: 1

    I was always partial to the minimax game playing algo with alpha-beta pruning. I think it is rather cool that you just start lopping off whole chunks of the tree, and you're always searching for that one branch that fits you best and your opponent worst.

    --

    "What we elect to call imagination is mere combination of things not heretofore combined." - Frank Norris

  69. Pardon me... by SSJ_Ramon · · Score: 1

    ...but did you say Al Gore rhythms?

    --

    This .sig is void where prohibited, no purchase necessary.
  70. Dr. Fun cartoon by PD · · Score: 4, Funny
    1. Re:Dr. Fun cartoon by Anonymous Coward · · Score: 0

      I proudly admit that that made me shudder and vocalize disgust.

  71. What about the by graphicartist82 · · Score: 1

    CowboyNeal algorithm? CowboyNeal = SQR(CowboyNeal * CowboyNeal)

    1. Re:What about the by sacherjj · · Score: 1

      I always wondered why CowboyNeal was so positive about everything...

    2. Re:What about the by t · · Score: 2, Funny

      CowboyNeal could be exp(-ix) which would then make him purely imaginary...

  72. If you have to ask by sinserve · · Score: 1, Troll

    "What is your favorite algorithm", then you have no idea what an algorithm is.

    Let me put it in common english, so Joe-Six-Pack can understand:

    "Hey slashdot readers, what your favorite way of solving problems".

    Yessir, we have "a" favorite way to solve problem*s*.

    A new low slashdot, a fucking new low.

    1. Re:If you have to ask by sinserve · · Score: 2

      I was going to protest this unfair moderation of my post (-1 Troll)
      But I will execute Jessus's favorite algorithm, and turn the other cheek.

      .solution:
      mov eax, [input]
      cmp eax, bitchslap
      jz .solution
      mov ebx, cheek_number ; boolean, toggles between left and right cheek
      neg ebx ; inverting the value, changes cheek number
      mov ah, [turn] ; movement type
      mov dl, PORT_CHEECK ; /dev/cheek's port# defined in asm/i386/ioctl.h
      out dl, ah ; write to the cheek port
      return

  73. random by brondsem · · Score: 1

    random number generators
    I don't know any names, but they're used in lots of applications

    --
    "a quote" -me
  74. how about breaking RSA? by vladkrupin · · Score: 1
    or breaking this. Or this (a few others come to mind too).

    Heck, just with crypto breaking you can probably find over a hundred different algorithms that are utilized in breaking crypto only. This way we can get to a thousand in no time, we just need more paranoid developers... ;)

    --

    Jobs? Which jobs?
  75. CiSE Top 10 by Vireo · · Score: 1, Insightful
    The Computing in Science and Engineering magazine published in Jan/Feb 2000 a "Top 10 Algorithms of the Century" article by Jack Dongarra and Francis Sullivan. Their choices for the most important / useful algorithms are:

    Metropolis algorithm for Monte Carlo

    Simplex Method for Linear Programming

    Krylov Subspace Iteration Methods

    The Decompositionnal Approach to Matrix Computations

    The Fortran Optimizing Compiler

    QR Algorithm for Computing Eigenvalues

    Quicksort Algorithm

    Fast Fourier Transform

    Integer Relation Detection

    Fast Multipole Method

    1. Re:CiSE Top 10 by Inthewire · · Score: 1
      Remember the header that preceded this thread? The thing where they introduce the story? There was a link to a previous thread...a thread discussing that same top ten list. Amazing, isn't it?
      Stridar writes "A paper presented in a recent article quotes Donald Knuth as saying the computer science has 500 deep algorithms. He mentions that Euclid's algorithm is one of the most important, and he seems to agree with the idea that CS will be mature when it has 1000 deep algorithms. What I would like to ask Slashdot is the following. What are the most important algorithms in CS? What is your favorite algorithm? And finally, what are the outstanding problems for which algorithms would be immediately placed in the "Top 1000" category." We had an older story where two scientists picked their top ten algorithms .
      --


      Writers imply. Readers infer.
  76. algorithm example: long division by upper · · Score: 2, Informative

    An algorithm is a process for doing something. Perhaps the best example for non-programmers is long division, the way you learned to divide multi-digit numbers with pencil and paper. The basic mathematical definition of division is that it's the inverse of multiplication, which is a fine definition of an operation but doesn't tell you how to divide two numbers. Long division is a procedure which gives you the answer. Other procedures are possible.

    This may sound like I'm describing a program, or a piece of code. A piece of code can implement an algorithm, but many different pieces of code can implement the same algorithm. An algorithm has a specific mathematical context in which it works -- e.g. the dividend is not zero. The piece of code has specific to a computational context -- written in C, divisor is in variable x, dividend is in variable y, quotient ends up in z, all of which are single precision floating point.

    What's a deep algorithm? That's subjective, but I'd say it has to either be non-obvious or become obvious only after you learn a nontrivial piece of theory. There's probably an aesthetic component as well.

    1. Re:algorithm example: long division by magic · · Score: 2
      I believe algorithms are also guaranteed to terminate in finite time.


      -m

    2. Re:algorithm example: long division by jcast · · Score: 1

      Would you like to inform us what you think the Halting Problem is all about?

      --
      There are reasons why democracy does not work nearly as well as capitalism.
      -- David D. Friedman
  77. "You'll be strung-up by your toenails... by CheapScott · · Score: 1

    ...if you do this on the school's mainframe!"

    --A Serious Warning from my Freshmen Comp Sci Instructor (14 years ago).

    main() {
    while(1)
    fork();
    }

    1. Re:"You'll be strung-up by your toenails... by JacobO · · Score: 1

      I thought you were supposed to add a malloc(1024) in that loop too...

      Sheesh!

  78. False by Anonymous Coward · · Score: 0

    The halting problem is regarding PROGRAMS, not algorithms.

    Programs and algorithms are _not_ the same thing.

    1. Re:False by heliocentric · · Score: 2

      The halting problem is regarding PROGRAMS, not algorithms.

      Programs and algorithms are _not_ the same thing.


      You are somewhat correct, but very misguided. The thread here is that if an "idea" doesn't terminate then it's not an alg. I can clearly devise an alg. to test another alg. / program. However, the halting problem states that I can never know for sure if this input ever terminates. Here, the input is a program, it's not a program itself. Infact, when we talk about TMs we often mention "On input which is the encoding of a machine..." thus we are supplying as input what you call a program.

      I will stipulate that not all algs. are programs, since I can device a non-deterministic alg. (even using an oracle) that I can not program in the same way (ie, I can't make it poly time on a deterministic machine). However, I would like to know of one program that can not be defined via an alg.

      --
      Wheeeee
  79. Swap! by FernandoValenzuela · · Score: 1

    The Greatest Algorithm Ever Created:

    swap (int* a, int* b)
    {
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
    }

    1. Re:Swap! by Anonymous Coward · · Score: 0

      I believe 3 XOR instructions would perform the same function, without the need for a third variable...but of course, this is only efficient for constructs in a practical manner.

    2. Re:Swap! by ChicagoFan · · Score: 1
      The Greatest Algorithm Ever Created:

      swap (int* a, int* b)
      {
      int tmp;
      tmp = *a;
      *a = *b;
      *b = tmp;
      }

      Bah. Long live C++!

      template &lt class Visa>
      swap(Visa& a, Visa& b)
      {
      Visa tmp;
      tmp = a;
      a = b;
      b = tmp;
      }

      "Visa. It's every type you want (it) to be."

      ChicagoFan

      (this crap here only to get past the "too few characters per line" filter)

    3. Re:Swap! by FernandoValenzuela · · Score: 1

      oh sure, if you want to overload operator = for every class...

    4. Re:Swap! by ChicagoFan · · Score: 1

      oh sure, if you want to overload operator = for every class...

      1) Without operator=, I couldn't swap two elements of a class even if I wrote a swap function specifically for that class instead of using a template. (unless you had a member swap(), I guess, but then you have to write a member swap() instead of a member operator=).

      2) Operator= exists automatically for all classes. You only need to overload it if you are specifically allocating dynamic memory or using other such resources, and often you can just make your member variables objects (instead of pointers to objects) and let their functions do the dirty work.

      So it's not as much work as you think.

      ChicagoFan, probably IHBT

    5. Re:Swap! by iangoldby · · Score: 1

      Nah! Save 4 bytes:

      swap (int *a, int *b)
      {
      *a ^= *b;
      *b ^= *a;
      *a ^= *b;
      }

      The sad thing is I had to look up the C operator for exclusive-or.

    6. Re:Swap! by Anonymous Coward · · Score: 0

      Newer AMD processors have a swap instruction, I would guess Intel processors do also.

    7. Re:Swap! by GMontag451 · · Score: 2

      swap (int a, int b) { a = a + b; b = a - b; a = a - b; } // no pesky third variable

    8. Re:Swap! by Anonymous Coward · · Score: 0

      I've always been wondering how to write the swap matrix as a product of identity matrices with one modified row. That's hot!

      [1 -1][1 0][1 1] = [0 1]
      [0 1][1 -1][0 1] [1 0]


      Any way of doing that with integer coefficients other than 0,1,-1 ?

  80. Lewis Caroll's day of the week algorithm by madmancarman · · Score: 2, Funny
    My personal favorite (and one I use all the time) is Lewis Caroll's algorithm that allows you to find the day of the week (Monday, Tuesday, etc.) for any given date (for example, August 15, 2001 would return a Wednesday). It's pretty useful with our school's attendance system, which is written in Perl and run on Apache.

    Personally, I find it interesting that this algorithm was developed by the same guy who wrote Alice's Adventures in Wonderland. A guy I teach with showed it to me a couple months ago, and I'm planning on using it in class soon to teach some programming concepts.

    First they ignore you, then they laugh at you, then they fight you, then you win. -- Gandhi

    --
    First they ignore you, then they laugh at you, then they fight you, then you win. -- Gandhi
  81. How about backpropogation? by Anonymous Coward · · Score: 0

    The generalized delta stuff pretty much saved the whole neural net scene from itself. Backpropogation (aka the generalized delta rule) allowed neural networks to learn the infamus xor problem providing a renewed interest in neural network research...

  82. Al Gore Rhythm? by ctp · · Score: 1

    Ever seen that man dance? He has no rhythm!!! What's all the fuss about???

  83. Not all answers are in Knuth by Goonie · · Score: 2
    Further to your point, there is still a need for new algorithms.

    There are plenty of real problems for which the "best" algorithm doesn't yet exist, and you come across them both in academia and in industrial settings.

    --

    Any sufficiently advanced technology is indistinguishable from a rigged demo
    --Andy Finkel (J. Klass?)
  84. I dunno... by locoluis · · Score: 1

    I didn't mean to make sense. :)

  85. Best texts on algorithms by merkel · · Score: 2, Interesting

    So what are the best texts on algorithms? I mean texts that describe the algorithm and cover the etiology and perhaps importance rather than just being a cookbook or leaving everything as an exercise for the reader?

    The Knuth books? Or is there something better?

    1. Re:Best texts on algorithms by CrayzyJ · · Score: 1

      Introduction to Algorithms - Cormen, Leiserson, and Rivest - is the defacto standard. It can be a hard read, but it has *everything*.

      --
      Holy s-, it's Jesus!
    2. Re:Best texts on algorithms by Anonymous Coward · · Score: 0

      BULLSHIT! It doesn't even have AVL trees!

      I know leiserson, too, and let me tell you, i wouldn't trust the accuracy of *anything* he wrote.

  86. Finite Element by the+eric+conspiracy · · Score: 2, Interesting

    I'm surprised that nobody has mentioned finite element analysis as the most important algorithm. Just about any modern structure built today is analyzed to determine it's structural characteristics using FE analysis. From a car bumper to the Sears Tower, it's all about FE.

    1. Re:Finite Element by Gary+Yngve · · Score: 1

      Finite elements are really more of a modeling technique. The interesting algorithms are then how to solve the differential equations over the finite elements.

  87. In place swap of two variables by WeeGadget · · Score: 2, Interesting
    OK... It's not deep... but using XOR to swap the value of two variables is pretty fun.
    No temporary storage needed!
    // Swap A and B
    A ^= B;
    B ^= A;
    A ^= B;
    // Swap of A and B complete

    Jono

    1. Re:In place swap of two variables by Gary+Yngve · · Score: 1

      And most processors these days have a single machine instruction to do a swap for you. Of course their main motivation is atomicity for concurrency. But these days it may be better just to code swaps the old-fashioned way (with the temp variable). Besides having it being easier to read, the compiler would have a better chance figuring out exactly what you are doing and optimizing it for you. The compiler is your friend and you should not try to outsmart it.

    2. Re:In place swap of two variables by Tony+Hoyle · · Score: 3, Informative

      Indeed - the last time this came up I did some benchmarks. The 'old fashioned way' using temp variables when optimised runs about twice as fast as the xor version.

      In not-quite-assembly it looks like:

      foo(cx,dx)
      mov ax,cx
      mov bx,dx
      mov ax,ax xor bx
      mov bx,bx xor ax
      mov cx,ax
      mov dx,bx

      vs.

      foo(cx,dx)
      mov ax,cx
      mov bx,dx
      mov cx,bx
      mov dx,ax

    3. Re:In place swap of two variables by Fulcrum+of+Evil · · Score: 2, Insightful

      In somewhat saner assmbly, it looks like:

      swap(r4, r5)
      xor r4, r4, r5
      xor r5, r4, r5
      xor r4, r4, r5

      versus

      mov r6, r4
      mov r4, r5
      mov r5, r6

      of course the real answer is 'oh, that's nice'
      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    4. Re:In place swap of two variables by jakew · · Score: 1

      Wish I had mod points. I was just about to type this very thing. So nice to know that not everyone is x86-centric.

      Of course, the xor version is more efficient on sensible ISAs if you take register allocation into account.

    5. Re:In place swap of two variables by Ironpoint · · Score: 1


      xor ecx,edx
      xor edx,ecx
      xor ecx,edx

      Same opcode count PLUS one more register is free for something else. If one operand is a memory address, then it uses only one register.

      And if we are swapping 32-bit floats, we don't have to use the fpu.

    6. Re:In place swap of two variables by epine · · Score: 1


      xor r4, r4, r5

      This is supposed to be sane? I know of many human languages with the grammatical structure:

      verb subject object indirect-object

      Not.

    7. Re:In place swap of two variables by epine · · Score: 1


      The floating point unit doesn't have an xor capability in any modern chip I've seen, unless the IA-64 bit slicing facilities for floating point manipulation include this.

    8. Re:In place swap of two variables by epine · · Score: 1


      The xor swap only makes sense if you use it to swap a bit field within the integral value.

      Off the tip of my fingers I think it goes like this:

      b ^= a;
      a ^= (b & bitmask);
      b ^= a;

      Yes, that should be right since if the second statement is rendered idempotent by a zero bit in the bitmask it boils down to this:

      b ^= a;
      b ^= a;

      And we are back to the beginning again.

      There's no good reason a compiler couldn't be coded to recognize this sequence of steps and apply instruction level optimizations, such as on x86 if your constant bitmask is just swapping the low byte. The single byte swap instruction could be substituted mechanically.

      The program code:

      uint32 a, b;
      b ^= a;
      a ^= (b & 0xFF);
      b ^= a;

      Would be generated by the compiler as:

      swap al, bl

      Of course I'm joking that anyone would implement this optimization in a real compiler. But then take a look at recent developments to automate the generation of SIMD instructions for conventionally coded loops.

      I think the boundary between what helps and what hinders the compiler is becoming extremely blurry.

    9. Re:In place swap of two variables by Fulcrum+of+Evil · · Score: 1

      Very sane.Instructions are by and large OP DST SRC SRC

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
  88. Quantum Algorithms by Lictor · · Score: 2

    I'm going to make the brave supposition that quantum computers will overcome the decoherence problem and scale to non-trivial sizes.

    (Even if this doesn't happen, the following algorithms still deserve honorable mention for being the first to make use of quantum parallelism to give results unattainable thus far by classical algorithms):

    - Shor's algorithm for factoring and discrete log
    - Grover's search algorithm

    1. Re:Quantum Algorithms by NoBeardPete · · Score: 1

      I think it's worth going into more detail on these, because I suspect most people don't know much about them. I won't try to explain Shor's factoring algorithm, because I never really managed to get it all in my head at once. It might have helped if I wasn't trying to carry 4 technical classes on top of my brutal physics lab when I was trying to understand it.

      Grover's search algorithm, though, I remember quite well. It's beautiful in its simplicity and elegance (which is a large part of why I still remember it), yet quite powerful. Here's what it does:

      We have some function F returns 1 on exactly one out of its n inputs. Grover's search algorithm lets us find the value x such that F(x) = 1, and it lets us do that in order sqrt(n) time. Classically you can't do any better than just searching through the space of inputs, trying each one, which takes order n time.

      Damn.

      So, having covered the fact that it is mighty powerful, I'll say a little about how it works. First, we construct an input x which is a superposition of all possible inputs. In particular, this means it is fractionally 1/n the right answer, but is (n-1)/n some wrong answer. We pump this x through f (and a few other operations) and then combine the output with the input. Each wrong answer suffers a little bit of destructive interference, while the right answer undergoes constructive interference. Rather, rinse, repeat, and after a number of steps that goes like sqrt(n), all of the wrong answers have completely cancelled out, and all that is left is the right answer!

      Yeah, so I know this is hard to get across in this kind of short text dohickey, but this is such a cool algorithm, I had to try anyway. My success... well, I guess that depends on how cool you think the Grover algorithm is now.

      --
      Arrr, it be the infamous pirate, No Beard Pete!
  89. How about Genetic Algorithms? by Ipsilon · · Score: 1

    They can solve a large set of optimization problems and the basic idea is very simple.

    --

    The opinions in this comment are subject to GPL, you can copy, modify and redistribute freely (as in speech).

    1. Re:How about Genetic Algorithms? by Ipsilon · · Score: 1

      Interesting opinion, but I've used Genetic Algorithms for different kind of problems like optimization, machine learning, etc. Yes, they are damn slow, but in many problems there is no other feasible solution.

      --

      The opinions in this comment are subject to GPL, you can copy, modify and redistribute freely (as in speech).

  90. My favorite AlGoreithm by SecurityGuy · · Score: 5, Funny

    Gotta be inventing the Internet! How could you top that?

    1. Re: My favorite AlGoreithm by aralin · · Score: 2

      Gotta be inventing the Internet! How could you top that?

      You are in wrong section here. This is 'AlGoreism'

      --
      If programs would be read like poetry, most programmers would be Vogons.
    2. Re:My favorite AlGoreithm by deadtreerus · · Score: 1

      Tipper throws her hat over Al's deep ALGorythm probe.

      --
      "It just dosen't matter."Bill Murray from The Razors Edge
    3. Re: My favorite AlGoreithm by Hal-9001 · · Score: 2

      If you read Knuth vol. 1, you'll discover that "algorism" is a deprecated word for "algorithm", so the pun still works... ;-)

      --
      "It take 9 months to bear a child, no matter how many women you assign to the job."
  91. Re:Theoretically interesting/Practically irrelevan by ryanflynn · · Score: 0

    >he: You're taking the science out of computer science.

    yeah... and if you wanted to look at an eclipse from another continent you should go and build your own telescope with your bare hands and swim on over.

  92. The funniest algorithm by leob · · Score: 4, Interesting
    The funniest, while quite deep, algorithm is a text compression (or, rather, transformation) algorithm called Burrows-Wheeler Transform. It is quite a surprizing realization that you can write the letters of a message in a somewhat "sorted" way, but it is still possible to restore the message. The algorithm was only invented in the 1980's, but it is so simple and cute that even (bright) children can understand it and use it for "cryptograms". I am somewhat surprized that it was not invented earlier.

    Speaking of sorting, the scientists contemporary to Galileo used it to "patent" their yet unverified ideas and hypotheses by publishing a "one-way hash" of the statement describing the idea by alphabetically sorting the letters of that statement. E.g. a hypothesis "Mars has two satellites" will be "Aaaeehillmorsssstttw". Of course, to be secure, the statement must be much longer.

  93. Re:Theoretically interesting/Practically irrelevan by hij · · Score: 2, Insightful

    Do you mean that it is irrelevant to you? For some people, Knuth for example, the obsession with algorithms is very important. Thank goodness that they did do this so that you and I could borrow their work and not invent it ourselves. Some people spend a great deal of time trying to construct and refine algorithms. I would guess that few people in our society care, but it is greater than .001% of the people in the scientific computation communittee.

    --
    Believe nothing -- Buddha
  94. my favs by Anonymous Coward · · Score: 0

    maybe I don't get to do serious algorithms enough, but I enjoyed

    Dynamic Dijkstra

    Simulated Annealing

  95. Douglas Adams was right by Dances+with+Sheep · · Score: 2, Interesting

    Natural selection is the algorithm that solves all of life's problems :)

  96. Djikstra's Communicating Semaphores by Ungrounded+Lightning · · Score: 3, Interesting

    My favorite is Djikstra's Communicating Semaphores, along with the related algorithms documented in Djikstra & Riddle's paper "The 'T.H.E.' multiprogramming System".

    With Mark Weiser's addition of the "T" primative (more commonly called "non-blocking P" i.e. "Try to P but if that would block return an error flag instead.") you have a fantastically powerful tool in a tiny amount of code.

    For instance: I was able to implement a kernel for an actor-based, real-time, prioritized, preemptive multitasking system, including initialization code, an idle task, and a minimal startup task table (i.e. everything but the application tasks and device drivers):

    - In under 512 bytes of code and initialization data.
    - On an 8080.

    Communicating P, V, and T, (along with a flavor of "V" doubling as a return-from-interrupt) are a complete set of primitives for such work.

    For those not familiar, an "actor" in this context is a class such that each instance of that class or any subclass of it is a separate thread of execution. Messages are exchanged between threads via queues on semaphores rather than C++ member function calls / Smalltalk message sends, but otherwise all the object-oriented concepts apply directly.

    Communicating Semaphores handle locking (like normal semaphores), message queueing, and resource allocation (by holding a queue of messages, each of which represents, or actually is, a resource).

    "T" lets interrupt routines run initially as parasites on the interrupted task, then "T" a free-message-buffer queue, fill in the message, and "V" it to the incoming-work semaphore of the actual service routine as the interrupt exits - provoking a context switch if the service routine is higher priority than whatever was running. The interrupt routine can punt and return to the interrupted task if no buffers are available.

    --
    Bantam Dominique roosters crow a four-note song. Once you've heard it as "Happy BIRTHday" you can't NOT hear it that way
    1. Re:Djikstra's Communicating Semaphores by CvD · · Score: 1

      The name's Dijkstra, not Djikstra. :-) The Dutch 'ij' is somewhat equivalent to the english 'y', although we have the 'y' too. The 'ij' is actually one letter "unit" in a word.

      And yeah, semaphores are cool!

      Cheers!

    2. Re:Djikstra's Communicating Semaphores by jakew · · Score: 1

      Sounds interesting. Got any documentation or source?

  97. Parsing, interpreration and game theory by MagikSlinger · · Score: 2

    There's some good ones (like QuickSort) that should be #1, but here's a random collection of some algorithms I find interesting:

    • The recursive-descent parser generator
    • Regular expression to DFA algorithm (it's its own proof!)
    • The Lisp interpreter written in Lisp (and no you can't use eval). An elegant algorithm demonstrating how data and code can become one.
    • The Mini-Max Algorithm
    • The Backfeed Neural Network Algorithm
    • Euclid's greatest common divisor algorithm (technically not a computing science algorithm)
    • Mandelbrot set algorithm
    • The Ray-Tracing algorithm
    --
    The bitter lessons of a veteran coder: http://bitterprogrammer.blogspot.com
  98. Say no to algorithms in CS! by NicolaiBSD · · Score: 1

    algorithms in CS? I can't say this often enough: You don't want none of them fancy-schmanzy algorithms in your Counterstrike, they'll ruin your ping for sure.

  99. Bresenham Line Algorithm by sl3xd · · Score: 2

    My vote: The Bresenham Line algorithm. It provides the most efficient method to draw arbitrary lines on a raster (ie. pixel-based) screen. All 3D Graphics are heavily dependant on this beautiful algorithm.

    There have been improvements to the Bresenham line, effectively quadrupling the draw speed over the base Bresenham algorithm.

    But the base aspect of Bresenham's work is critical: It allowed the drawing of lines on our computer screens using integer, rather than floating point, arithmetic. 3D Graphics wouldn't be the same without his contribution.

    --
    -- Sometimes you have to turn the lights off in order to see.
    1. Re:Bresenham Line Algorithm by RoadWarriorX · · Score: 1

      Yes! Without Bresenham, I could not have spent a good portion of my life playing Quake... ;-)

  100. The most obvious by compass46 · · Score: 1

    #include

    main()
    {
    for(;;)
    {
    printf ("Hello World!\n");
    }
    }

  101. Square Root Algorithm by CTalkobt · · Score: 1

    A simple and somewhat efficient algorithm for finding the square root of a number goes as follows:

    n = # ( say 25 ).
    Count the number of sucessive odd numbers that add up but not over the target number.
    eg: 1+3+5+7+9 = 25
    ....1.2.3.4.5 so 5^2 = 25.

    Who knows what this is really called?

    --
    There's a gorilla from Manilla whose a fella that stinks of vanilla and has salmonella.
    1. Re:Square Root Algorithm by Utopia · · Score: 1

      Thanks for the algorithm.
      I never realized that
      1 + 3 + ... + (2n-1) = n^2

    2. Re:Square Root Algorithm by Anonymous Coward · · Score: 0

      While it appears true in the case you mentioned, I don't believe that works in general.

    3. Re:Square Root Algorithm by knulleke · · Score: 1

      No, he's not saying that. You add where you should count.

      --
      no sig error.
  102. cute algorithms by Gary+Yngve · · Score: 1

    the quadratic algorithm for solving the Stable Marriage problem... I've been wanting to run it on a bunch of friends to see what bizarre matches came up... (run it twice, to be both male-optimistic and female-optimistic).

    Sweepline algorithm for Voronoi diagrams.
    The sweepline (directrix) creates parabolas around the points (foci). If illustrated right, these look like breats and make for a humorous lecture.

  103. Cayley-Purser is broken by Anonymous Coward · · Score: 0

    Cayler-Purser isn't all that's is cracked up to be (no pun intended). It was hailed by the media, but only because it was primarily developed by Sarah Flannery, a 16 year-old girl.

    It lasted perhaps a week of analysis before it was broken.

    1. Re:Cayley-Purser is broken by halfpastgone · · Score: 1

      yeah you're right. Sarah Flannery actually cracked it herself. link here.

      --
      "I can't understand why people are frightened by new ideas. I'm frightened of old ones."
  104. 2 killer algorithms by Anonymous Coward · · Score: 0

    2 killer algorithms:

    1) google algorithm. too bad some people are startint to cheat it, but it still rocks my world.

    2) brute force. I mean like come on, it's easy to code in any situation and it works.

  105. OT - What are the most common ones in use by wrinkledshirt · · Score: 1

    Sorry, this stuff is all super-Greek to me. I thought I was pretty smart for finally getting the Quicksort algorithm, but even then I needed the pretty Java applet to show how it worked.

    What I'm wondering is, what sorts of algorithms are in use all the time that we don't really know about? That article about the top-ten algorithms of all time listing some pretty exotic-sounding things, claimed that many of those algorithms were probably in use on the computer right now. Is that really the case? Are there many algorithms in use for the Linux kernel, for instance?

    --

    --------
    Bleah! Heh heh heh... BLEAH BLEAH!!! Ha ha ha ha...

  106. Floyd's Algorithm by Anonymous Coward · · Score: 0

    All pairs shortest path algorithm...This is my favorite algorithm from college. It solves a difficult problem and yet it is very simple.

  107. btree by Anonymous Coward · · Score: 0

    The good old btree and the balanced btree.
    Hashing.
    These are two I use every day.

  108. You're kidding yourself by edhall · · Score: 4, Insightful

    That's a bit like saying that there is no need to understand calculus because Newton and company already figured it out for you.

    To the professional programmer an algorithm is a tool, and like any other kind of tool it is important to know how it works even if you didn't invent or produce it yourself.

    This may suddenly dawn on you when you're coding an algorithm out of a book, and find you don't know whether it's safe to take a particular shortcut or not because you don't understand the algorithm well enough to analyze the implications. Or you're looking at some values in a debugger and can't figure out if they're correct or have been clobbered by a bug because you don't understand the algorithm well enough. And so on.

    -Ed
    1. Re:You're kidding yourself by FatHogByTheAss · · Score: 1
      To the professional programmer an algorithm is a tool, and like any other kind of tool it is important to know how it works even if you didn't invent or produce it yourself.

      It is far more important that someone know when to apply a particular tool to solve a problem, rather than knowing the detail of the tool itself.

      I would much rather have developers that know when to apply a given algorithm, even if they can't describe the detail from memory. Most true CS algorithm problems have been solved a zillion times.

      Productive engineers apply those tools to their problems, rather than build those tools themselves.

      I can't tell you what makes the blade in my circular saw go round and round, but I know what to use if I have to cut wood.

      --

      --
      You sure got a purty mouth...

    2. Re:You're kidding yourself by t · · Score: 2, Insightful
      Man that's a crappy example. You've never heard of the electric motor? Too quick to post perhaps?

      Also, your example also exemplifies why you need to understand the tools you use. What if you were in the midst of a storm, standing in pools of water sawing 2x4's to secure bits of your house. If you understood the tool you would know that water is not compatible with its use.

      One day all we'll have are people who only know how to plug doohickeys together.

      t.

    3. Re:You're kidding yourself by edhall · · Score: 2

      Like I said, you're only kidding yourself.

      What makes more sense: learning a long list of facts concerning each of a long list of algorithms, or learning the much smaller number of principles behind the algorithms themselves? The latter sort of knowledge -- "deep" knowledge -- is harder to acquire, but it is a much more useful form of learning than the rote memorization of facts. With it, you'll have the insight to evaluate the suitability of an algorithm without dredging up a long list of memorized do's and don't's.

      Understanding an algorithm lets you adapt it rather than using it blindly. For example, the same principle of partitioning that's behind quicksort also yields fast algorithms for finding the top N items in a large list without having to sort the entire list. It also allows you to adapt quicksort to work on linked lists without first copying them into an array. There are dozens of variations of the principles behind quicksort that have potential uses -- variations you're not likely to find in a library. (I only chose quicksort because some many posts here mention it; most algorithms have similar mutability.)

      If you don't understand the principles behind what you do, you've no right to call yourself an "engineer."

      -Ed
  109. Maybe I'm Shallow by 4of12 · · Score: 2

    But the first time I saw a recursive algorithm (eg, that for n!) I was quite impressed.

    --
    "Provided by the management for your protection."
    1. Re:Maybe I'm Shallow by kubrick · · Score: 2

      Recursion may not be deep, but it is definitely elegant :)

      --
      deus does not exist but if he does
  110. One Vote for Newton! by jat2 · · Score: 2, Interesting

    What about Newton's Method (and its variants like Quasi-Newton and Gauss-Newton)? This algorithm solves a system of nonlinear equations iteratively by solving a sequence of linear systems of equations. With Newton's method, one can use the extremely effective matrix decompositions (QR, LU, etc.) to solve nonlinear equations. Under typical conditions, it exhibits quadratic convergence (basically, the number of decimal places of precision double after each iteration). Plus, it is very easy to understand. (It is taught in many freshman calculus classes.)

    1. Re:One Vote for Newton! by Gary+Yngve · · Score: 1

      Newton's Method is slick, but remember that it does not guarantee convergence at all, especially in the presence of zero second derivatives. For 1-D, you can couple Newton with Regula Falsi. For higher dimensions, Levenberg-Marquardt works surprisingly well given that it heuristically chooses whether to behave more like Newton or more like gradient descent.

    2. Re:One Vote for Newton! by jat2 · · Score: 1
      Generally speaking, one really means "Gauss-Newton" when referring to "Newton methods." The GN algorithm (which I mentioned in my original post) works by "dampening" the Newton step via a 1-dimensional optimization subproblem called a line search (e.g. Armijo), thus avoiding "overshooting" the root.

      Most professional implementations use damped Newton methods (like GN), which are globally superlinearly convergent. In practice, GN is only merely superlinearly convergent for the first few iterations before moving close enough to the root to converge quadratically.

      The Levenberg-Marquardt algorithm is a quasi-Newton algorithm (which I also mentioned in my original post) because it estimates the Jacobian matrix of the nonlinear function instead of always using the exact Jacobian. In this way, there are less function evaluations required per iteration at the cost of superlinear convergence instead of quadratic.

      As far as nonlinear programming is concerned, no algorithm beats the class of Newton-like algorithms for their generality, efficiency and elegance. There are even a few different flavors of Newton algorithms that can be used to solve nonsmooth equations and their ilk! (The Bouligand differentiable Newton algorithm can solve systems of variational inequalities and complementarity problems.)

      For an excellent reference, see Numerical Methods for Unconstrained Optimization and Nonlinear Equations by Dennis and Schnabel.

  111. My favorite algorithm: by Anonymous Coward · · Score: 0

    In. Out. Repeat.

  112. Sorts by Anonymous Coward · · Score: 1, Interesting

    Sorts of all types. Weve got bubble sorts for the kids. Merge sorts for singles. And quick sorts for couples and for all you real CS people out their tell me what the Big O stats for a merge sort are?

  113. LZW by Anonymous Coward · · Score: 0

    duh..

  114. A considered list with footnotes by Tupper · · Score: 2, Informative
  115. 1000 is too naive by B.D.Mills · · Score: 5, Interesting

    500 deep algorithms, 1000 is maturity? To me this sounds a bit like like Bill Gates saying that 640K is enough for anyone, or the ancient Greeks saying that mathematics is mature because Euclid has codified his geometric axioms, or the head of the US patent office saying that everything's been invented in 1899. (All of which are probably apocryphal, but I digress.)

    It's too premature. Computer science has been around for little over half a century. Who knows what will be discovered in the centuries ahead? Mathematics is the source of many algorithms, yet new discoveries are being made in mathematics even now. Don't stop searching when we get to 1000. There's still going to be many new and wondrous algorithms to discover for the geniuses of the future.

    --

    The only thing necessary for the triumph of evil is for good men to do nothing. - Edmund Burke
    1. Re:1000 is too naive by Anonymous Coward · · Score: 0

      But 640k is enou...

    2. Re:1000 is too naive by compwiz3688 · · Score: 1

      They'll probably have more terms, like "Working 9 to 5" for 2000, "Retired" for 4000, and say "Old and gray" for 8000? :)

    3. Re: 1000 is too naive by aralin · · Score: 3, Funny

      Maybe, if you'd read what prof. Knuth said, you'd know he mentioned the 1000 algorithm as a START. About the number of algorithms the CS should have to START to be recognized as a relevant science.

      --
      If programs would be read like poetry, most programmers would be Vogons.
    4. Re: 1000 is too naive by NinjaGaidenIIIcuts · · Score: 1

      Most of these 500 algorythms were just been added for the needs of specific applications, CS is biased in the direction of "numbers that make money" and simply doesn't extend research "for fun", meaning hard research for things that appearantly don't give financial return.

    5. Re:1000 is too naive by epine · · Score: 1


      The maturity threshhold is not put forward in terms of the computer science field, but in terms of human intellectual limits. Mature fields have the characteristic that 90% of all progress comes from people who are highly specialized within their niche with completely unexpected connections popping up between subjects that were thought to be unrelated.

      A field is mature when much of the work concerns the relationships of things already known. CS isn't there yet.

  116. The single most important algorithm....EVER by MJN222 · · Score: 1

    Seeing as to how I just had an Algorithms assignment due today and spent a decent chunk of time solving the following problem to produce an algorithm, I'm gonna say its important. :-)

    Let G = (V,E) be a flow network with source s, sink t, and integer capacities. Suppose we are given a maximum flow in G.

    Now suppose that the capacity of a single edge (u,v) in E is decreased by 1. Give an O(V + E) time algorithm to update the maximum flow.

    --
    ---- Yay! I have a sig!
  117. Kollige by farmerzebra · · Score: 1

    One of the algorithms that was impressed onto me as one for a rainy day, was the radix sort. One variant of it can do some real magic. wish I could find my old notes on that...
    The other memorable one was Dykstra's shortest path alogorithm. The prof was Romanian, she spoke 12 languages, none of them english. I couln't undertand a word that woman said.
    I guess the CS field needs a comprehensive, but simple book on those 500 canonaical algorithms.
    Most CS books I've read seem to have been written to impress colleagues.

  118. Most important algorithms (or proofs) by Anonymous Coward · · Score: 0
    • normalisation (or "execution")
    • type inference
    • type checking
    • type inhabitation
    • unification
    • parsing / languages
    • divide & conquer
    • backtracking
    • induction / recursion
    • searching
    • sorting / ordering
    • mapping
    • (information) hiding / abstraction
    • modus ponens / implication elimination
    • resolution
    • congruence


    Here's a list of other interesting things, not necessarily algorithms:


    axiom, start, weakening, product, abstraction, application, conversion; pure type systems; Calculus of constructions; Lambda cube; weak/strong normalisation; BHK-interpretation; Gödel incompleteness; Peano arithmetic; natural deduction; Positional number systems; Curry-Howard isomorphism; 1st and 2nd order logic; Heyting algebras; Sequent calculus; Dependent types; Control operators; Lambda calculus; Category theory; Domain theory; Math; Universe; Everything; Word; Name; Symbol; God; Death; Infinite Time; Wrong Tool;

  119. Yeah every algorythm will be important by NinjaGaidenIIIcuts · · Score: 1

    But developers need a bit more of computer education to code applications using 80-bit floating-point format instead of double-precision.

    People still believe that SSE2 and its 64-bit precision will keep up with science applications, but that's not true.

    Is interesting that cpus like Itanium support 40-bit integer format and a lot of registers, packing a single 80-bit operation plus a 40-bit integer instruction (128-bit pack, a 8-bit header, 120-bit free) is easy using explicit paralelism and should be a big win for many scientific applications.

    1. Re:Yeah every algorythm will be important by Anonymous Coward · · Score: 0

      bah. its much simpler to let the compiler handle it. Java has infinite precision numbers such as BigInteger which allows you to specify arbitrary bit precision without wondering about all the fiddly bit stuff.

  120. My Personal Favorite by cube+farmer · · Score: 4, Funny

    Since I'm not formally trained as a computer scientist (I'm merely an information technology major, sorry), I can't offer much in the way of "deep" algorithms to this list.

    However, I can poke fun...

    My personal favorite algorithm is:

    1. Launch Web Site
    2. ??????
    3. Profit!

    (Ducks)

    --

    MacOS, Windows, BeOS, GNOME, KDE: they're all just Xerox copies

    1. Re:My Personal Favorite by Anonymous Coward · · Score: 0

      :-D

      Socks...

    2. Re:My Personal Favorite by Alsee · · Score: 2

      The Dot-Com gnomes!

      -

      --
      - - You can't take something off the Internet! That's like trying to take pee out of a swimming pool.
  121. The Scientific Method... by RazorJ_2000 · · Score: 1

    Why are so many people thinking of algorithms in terms of precise computations and, more literally, formulas? How about the Scientific Method as an algorithm? Without it, much of modern technology and science would be lost.

    --
    pi=sigma{n:0-infinity}[(1/16)^n][(4/(8n+1))-(2/(8n +4))-(1/ (8n+5))-(1/(8n+6))]
  122. Googles Search by Dalaram · · Score: 0

    One of the more interesting and useful algorithms is Googles PageRank feature, searching for the most useful and informative sites to make comprehensive searches. http://citeseer.nj.nec.com/page98pagerank.html

    --
    all my .sig are suck
  123. Hey, what about computational geometry? by xelph · · Score: 2, Insightful

    I would vote for Fortune's algorithm to compute the Voronoi diagram. It is a beautiful algorithm, which almost gave me an orgasm when I looked into its guts. I am shocked that no computational geometry algorithm was included in the top 10 list. Not only have they proved already to be extremely useful, but they are alos going to be more and more important in the future (especially in my case, working on next generation user interfaces).

  124. Self-contained recursive algorithm by Rui+del-Negro · · Score: 1


    recursive (ri kur'siv), adj. see 'recursive'.

  125. Computer science is the study of Algorithms by Meech · · Score: 1

    In my first computer science course, I was taught that computer science was the study of algorithms.

    1. Re:Computer science is the study of Algorithms by Requiem · · Score: 2, Insightful

      Computer science is the branch of mathematics dealing with computation and computability. Algorithms is contained in that. :)

  126. ROT13 by Rui+del-Negro · · Score: 1

    CSS is just a bad imitation of the ROT13 algorithm.

    1. Re:ROT13 by JonWan · · Score: 1

      Well I said it was important *not good*. It was really a serious nomination, just the part about the law made it funny (Well maybe not). If you think about it the studios wrangeled over the DVD format for a long time and only agreed to release movies after they were told that it was safe. It turned out to be a case of "Don't count your money before the DVD is hacked" and now they are stuck with it because of the sucessfull media blitz they have given DVDs. They make so much money now it will be hard to stop releasing movies on DVD. That is why they will spend so much money in Congress and the courts to get their way.

  127. Google's Mentalplex algorithm by Oink.NET · · Score: 2
    Try out Google's Mentalplex search.

    Or read the FAQ.

    For best results, you may need to reference the illustrations of proper use.

    I believe it breaks several laws of computational complexity, including NP-completeness and the halting problem.

  128. Lempel-Ziv?? [Re:Off the top of my head] by glyph42 · · Score: 1

    Lempel-Ziv compression is one of the most clunky, arbitrary, wasteful, inefficient, and widely-used compression algorithms available today. Get a clue about compression before you talk about it like that.

    I'd much sooner vote for LZP (for its sheer elegance) or the latest block-sort methods for their efficiency and speed.

    See compression.ca for some real numbers

    --
    Music speeds up when you yawn, but does not change pitch.
    1. Re:Lempel-Ziv?? [Re:Off the top of my head] by Hater's+Leaving,+The · · Score: 1

      The Lempel-Ziv family is a large one.
      Clunky - dunno what you're refering to here. LZ77 was poop in my book. That might count as clunky in your book.

      Arbitrary - Oh god yes. Several parameters to chose from, and then evolution such the the parameters would adapt themselves to the problem-size in question.

      Wasteful, inefficient - really? That's probably bad parametrisation, and a cheap and nasty entropy compressor as the back end. Throw it away, bolt on a decent entropy compressor. If you use the right kind of LZ variant, then you wont be more than 5-10% off the more high-tech modern ones.

      Maybe LZP is such a variant - I don't know of it, or not by that name - what's the particular twist that LZP has?

      Pretty please - URL will do.

      However, like you - I just love the BWT technique. Here's a great way to compress data - shuffle the tokens around! My jaw dropped when I first read their paper. Hmmm, I had some potential improvements to their transform, I must try them out some time. (They've probably been done already I'm sure).

      THL

      --
      Keeping /. cynic density high since the fscking Kwhores/trolls arrived.
    2. Re:Lempel-Ziv?? [Re:Off the top of my head] by glyph42 · · Score: 1

      URL for LZP:

      www.cbloom.com/papers/lzp.html

      Enjoy! Also be sure to check out the compression.ca site that I mentioned before.

      - GLYPH

      --
      Music speeds up when you yawn, but does not change pitch.
    3. Re:Lempel-Ziv?? [Re:Off the top of my head] by Hater's+Leaving,+The · · Score: 1

      Ah, Bloom. OK, I seem to remember that last time I was told to go look there my bloody PS viewer didn't work, and I gave up.

      You're a dude for posting that link - you'll get my eternal gratitude if you can post a good review of the PP* family. From teh one-line I've heard it doesn't seem like it's anything new at all, it's just an dynamic adaptive-depth modeller. And great for thrashing caches.

      THL.

      --
      Keeping /. cynic density high since the fscking Kwhores/trolls arrived.
    4. Re:Lempel-Ziv?? [Re:Off the top of my head] by Hater's+Leaving,+The · · Score: 1

      Holy Baloney - I invented LZP in about 1990. I needed a quick hack scheme to compress some text, and decided that the 1-bit guess was the way to go, as long as about 50% of the time the guess was correct, which is a simple matter of modelling well enough...

      It's funny - being nothing more than an amateur and hobbyist, you get to invent all kinds of things and never have a clue whether they're in the academic literature or not.

      THL.

      --
      Keeping /. cynic density high since the fscking Kwhores/trolls arrived.
  129. Favorite algorithm? by Sivar · · Score: 0

    Boy, that's geeky!
    Gotta love /.

    Mine: Euclid's GCD algorithm implimented recursively, like:
    //////////
    long gcd(long n1, long n2)
    {
    if(n1 != 0) n1 = gcd(long n1, long n2);
    return n1;
    }
    /////////
    ...because it looks so incredibly simple yet is fairly mind-bending when you follow it through the first time you see it. Also, put in a ternary statement it can be made one line which is always a nice accomplishment for an algorithm (despite being hard to read)

    --
    Computer Science is no more about computers than astronomy is about telescopes. --E. W. Dijkstra
    1. Re:Favorite algorithm? by Anonymous Coward · · Score: 0

      Yours is wrong. It does absolutely nothing except infinite loop unless n1 = 0.

    2. Re:Favorite algorithm? by Sivar · · Score: 2

      Heh, oops, make the line:
      if(n1 != 0) n1 = gcd(long n1, long n2);

      instead:
      if(n1 != 0) n1 = gcd(n2, n1 % n2);

      My mistake.

      --
      Computer Science is no more about computers than astronomy is about telescopes. --E. W. Dijkstra
  130. Skip list problems by cpeterso · · Score: 4, Insightful

    As I noted in another post, one problem with skip lists is that each node must be dynamically resizable because the number of forward pointers is changing and not known at compile-time.

    Another problem with skip lists is that they are not very friendly to multiple readers and writers because the nodes provide unfortunate concurrency "chokepoints". In a binary tree, for example, subtrees can be locked without blocking readers in adjacent subtrees.

    1. Re:Skip list problems by Subcarrier · · Score: 2, Informative

      one problem with skip lists is that each node must be dynamically resizable because the number of forward pointers is changing and not known at compile-time

      For a really long skip list you should consider using a skip list to store the forward pointers.

      --
      "I have opinions of my own, strong opinions, but I don't always agree with them." -- George H. W. Bush
    2. Re:Skip list problems by Anonymous Coward · · Score: 0
      For a really long skip list you should consider using a skip list to store the forward pointers.

      Then you just evaporated two of the primary benefits ("Simple to understand, ... doesn't require maintence ..."). This is a problem solved cleanly by red-black trees. And, when programmed in a generic way (std::map in the C++ STL), all the particular details of red-black trees need only be coded once.

      So at face value, I wouldn't assert skiplists as a "deep algorithm". Cute, maybe. But not deep.

    3. Re:Skip list problems by charmer · · Score: 1

      In IPDPS 2001 conference, there is a paper on Concurrent Priority Queues based on SkipLists by Shavit of Sun Micro. That demonstrates exactly the opposite of what you are saying.

    4. Re:Skip list problems by Sangui5 · · Score: 1

      Could you post a link? I know I've seen ways to make skiplists nicely concurrently accessed, but it is nice to have a reference, rather than just saying "Is so!".

    5. Re:Skip list problems by charmer · · Score: 1

      I searched google for skiplists, when I came across this presentation. I dont have a link handy.

  131. What, no else if SO? by T1girl · · Score: 2

    What then? Even if this was written by a fairly young teenager in 1995, it's kind of pathetic that seven years later there isn't some possibility of waking to the sound of a lover's voice, even if only in the imagination.

    1. Re:What, no else if SO? by Anonymous Coward · · Score: 0
      SO? Among slashdot readers?


      Get real!

    2. Re:What, no else if SO? by The+Man · · Score: 1

      How about: ... else if SO assert (get_temperature (HELL) 10); endif Why imagine something that will never happen? And hey, I'm 23. If you haven't woken to a lover's voice by 23, you never will. Pathetic? *shrug* C'est la vie.

    3. Re:What, no else if SO? by Anonymous Coward · · Score: 0

      Lovers are for the fool. Free yourself from this attachment, or else stray from the path towards god-realization. Celibacy is the ONLY way.

  132. What about interior point methods? by Anonymous Coward · · Score: 0

    How about interior points methods for solving constrained optimization problems?

  133. Actually he invented Spam by Ungrounded+Lightning · · Score: 2

    My favorite AlGoreithm [has] Gotta be inventing the Internet! How could you top that?

    Actually what Al Gore invented was Spam.

    Really.

    (The legislation he supported to open the Internet to commercial exploitation is part of why we can't do much about the spammers without further legislation.)

    His wire-all-the-schools-for-internet was also a trojan horse. It gives government an excuse to censor the net down to elementary-school level to "Save the Children".

    --
    Bantam Dominique roosters crow a four-note song. Once you've heard it as "Happy BIRTHday" you can't NOT hear it that way
    1. Re:Actually he invented Spam by compwiz3688 · · Score: 1

      His wire-all-the-schools-for-internet was also a trojan horse.

      So that's where the spam is coming from. :)

  134. the Art of Computer Programming by danny · · Score: 2
    Before trying to answer any of those questions, you should go off and read Knuth's The Art of Computer Programming ...

    Danny.

    --
    I have written over 900 book reviews
  135. Databases by Dr_Cornholio · · Score: 1

    Where would the world be without the Prof. Nijissen Algorithm. It is a complex algorithm but once you've used it a couple of times, you can create the most complex databases without even working up a sweat!

    --
    In Soviet Russia, the monkey spanks you!
  136. physical simulation, collision detection by NFW · · Score: 1
    My $0.02: LCP, penalty method, lagrange multiply, impluse method... some such physical simulation algorithm will belong in the list eventually (or maybe a few of them will). Probably a collision detection algorithm too, maybe nice fast polygon soup algorithm.

    This stuff is pretty niche right now (mostly just games and high-end simulations), but I think it will get find more widespread application as computing power increases.

    a cool LCP implementation

    a fun toy (yes, I'm biased) that uses the above

    --
    Build stuff. Stuff that walks, stuff that rolls, whatever.
  137. The Illegal Infinite Knowledge Algorithm by Anonymous Coward · · Score: 1, Funny


    The following must be *the* most important algorithm known. ;-) It --- if run sufficiently long enough, say, oh, a few forevers --- generates a representation of all possible knowledge that can be represented:

    (let ((y 0))
    (define knowitall
    (lambda (x)
    (begin
    (if (= x 0) (write-char #\.))
    (write x)
    (knowitall (+ 1 x)))))
    (knowitall y))

    Why? This algorithm generates (a decimal representation of) Champernowne's Constant, which is a / the (only known?) string that contains within it every possible substring of arbitrary length drawn from the same alphabet of characters. Warning: this algorithm is probably illegal, because it contains within it / will eventually generate DeCSS, the complete source code to every version of Microsoft Windows ever, the complete collection of all Mariah Carey's songs in MP3 format, the complete set of all the documents that Anderson shredded on behalf of Enron, the exact GPS coordinates of Osama Bin Laden at every moment for the rest of his life, George Bush's complete DNA sequence, etc. Enjoy! :-)

    1. Re:The Illegal Infinite Knowledge Algorithm by Xoro · · Score: 1

      Bah!

      Your cheesy scheme is no match for an infinite number of typing monkeys.

      --
      Kill, Tux, kill!
  138. Didn't anyone else spot it? by Anonymous Coward · · Score: 0

    There's an error in that algorithm. Can you spot it?

    It's Fibonacci, not "Fibinacci"

  139. The one algorithm of all time... by Subcarrier · · Score: 1

    The one algorithm of all time that I remember most fondly has got to be the Infocom parser. At the tender age of 14 I spend countless of hours trying to duplicate it in early BASIC. This, in retrospect, might not have been such a great idea...

    --
    "I have opinions of my own, strong opinions, but I don't always agree with them." -- George H. W. Bush
  140. Obviously... by Pig+Hogger · · Score: 2
    ... 42!!!

    That's what deep thought was all about, no?

  141. Please take care with the non standard file format by Anonymous Coward · · Score: 0

    As it happens my bizzare setup can deal with
    these so called "pdf" files, but in general
    stabdards based software will choke.

    So stick a "[pdf]" after the link. Please?

  142. Wavelets by michael_cain · · Score: 1

    In particular, the "lifting scheme" for constructing transforms -- it's fast, it's invertable, and it generalizes more easily to a variety of conditions.

  143. Everyday life needs algorithms by Pinball+Wizard · · Score: 2
    I wonder why geeky CS people have never applied algorithms to some of the vexing problems of everyday life.


    For instance, figuring out that most people exercise with an exponential algorithm and devising an O(log n) way to get ripped abs in less than 5 minutes a day.


    Or figuring out the shortest distance between meeting a beautiful woman and getting laid.


    Devising a "quick sort" routing that got you out the door in the morning 5 minutes after waking up.


    Perhaps an exponential growth algorithm for our bank accounts.


    Why is it we only apply algorithms to move bits around?

    --

    No, Thursday's out. How about never - is never good for you?

    1. Re:Everyday life needs algorithms by Fulcrum+of+Evil · · Score: 1

      Perhaps an exponential growth algorithm for our bank accounts.

      Oh, that one's easy. It's called compounded interest.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    2. Re:Everyday life needs algorithms by daveman_1 · · Score: 1
      Or figuring out the shortest distance between meeting a beautiful woman and getting laid.

      If you figure out how to optimize this one in a way that works every time, you will have solved all the important problems in the universe.

      --
      Russian Russian Russian RussianDollSig DollSig DollSig DollSig
  144. AI by ZaneMcAuley · · Score: 1

    I think the next important algorithm would be a good "Fitness" test algorithm for AI.

    --
    ----- Whats wrong with this picture? http://www.revoh.org:1234/whatswrong
  145. Cool algorithms by flonker · · Score: 1
    One of my favourite algorithms is one I found in Programming Pearls. Basically, using a bitfield to sort numbers in constant time, O(n), given that the numbers are unique. Something like:

    for i=MIN to MAX
    aout[ i ] = 0
    for i=0 to n
    aout[ ain[i] ] = 1
    for i=MIN to MAX
    if aout[i] == 1
    Do whatever with the now sorted output

    1. Re:Cool algorithms by Accelerated+Joe · · Score: 1

      Yeah, bucket sorting sure is cool! Radix sort would probably be more efficient here, unless your range is too small for the sorting method to matter.

      --
      They who would give up an essential liberty for temporary security, deserve neither liberty or security
  146. Normalization by Blackheart2 · · Score: 1

    Since this is a blatant popularity contest, I will submit my own, very biased, favorites. These are all ways of normalizing lambda-calculi.

    1. call-by-name evaluation
    2. call-by-need evaluation
    3. call-by-value evaluation

    Lambda-calculi are abstract models of computation which lie at the heart of functional programming languages. Terms of the lambda-calculus are programs, and present computable functions. A normalization algorithm lets you decide whether two terms (programs, basically) are equivalent---not merely syntactically (which is trivial), but semantically, i.e., whether or not they give the same results on the same inputs. This is an extremely important problem in the field of programming languages because it affects program reliability.

    The normalization methods mentioned below are important because they are decision procedures on closed terms of typed lambda-calculus, i.e., terms without any free variables. Call-by-name (cbn) is also a "semi"-decision procedure for untyped lambda-calculus (dynamically typed functional languages). This means that if two programs terminate, then they will reduce to the same thing using cbn.

    To put this in context: When you program in ML or Scheme or, more or less, LISP, you are using the call-by-value evaluation procedure, since arguments are evaluated before calls. When you program in Haskell (or Scheme with suspensions), you are using the call-by-need procedure, since arguments are evaluated on demand. And, if you are using Algol 60, you are using call-by-name, since arguments are evaluated every time they are demanded.

    Other candidates for `deep algorithms' in this vein are Gentzen's "Hauptsatz", or cut elimination procedure and the Hindley-Milner type inference algorithms.

    --

    BH
    Fools! They laughed at me at the Sorbonne...!

  147. Another Exception by restless_ne'erdowell · · Score: 2, Funny

    Don't forget about the outOfHotWaterException. If not caught properly, it results in a blue screen of freezing.

  148. yeah by Trepidity · · Score: 1

    I have one particular computer science professor who can barely program worth a damn. But he sure is good at discrete math.

  149. Drunkard's Walk by JLester · · Score: 1
    Drunkard's Walk of course!

    Jason

    --
    "FORMAT C:" - Kills bugs dead!
  150. Why algorithms ?? by matsh · · Score: 2

    I would say the number of unique patterns are much more important. At least to me in my everyday programming.

  151. Hmm by mlylecarlin · · Score: 2, Insightful

    Everyone is forgetting that simple tests count as algorithms. No one has mentioned Eistenstein's Criterion, or the Weierstrauss M test, or Miller's Primality tests. Some of these tests are quite deep, and at very least they bear consideration alongside some of the more obvious tests from CS, analysis, and basic math.

    Heh, I would say the deepest and most important algorithm is the process of induction :-P but I'd be shot.

  152. Bicycle Wheels by Anonymous Coward · · Score: 0
    There's no need to reinvent bicycle wheels, especially when there are high performance race car wheels free for the taking.

    Where can I get these free race car wheels? Will they fit on my bicycle?

  153. Dijkstra's Algorithm: All-pairs, shortest-path by SkewlD00d · · Score: 2

    Dijkstra's algorithm is very nice, and it's parallelisble too! I used a varation in a class called the Longest Common Subsequence algorithm and we had to parallelize it.

    Dynamic programming =)

    I also like radix sorting, BSP trees, and B+ trees. Memory managers (allocators/gc/swaping) are fun too.

    --
    The biggest trick the devil pulled was letting lawyers become politicians so they can write the laws.
    1. Re:Dijkstra's Algorithm: All-pairs, shortest-path by mikera · · Score: 2

      I agree that radix sorting rocks.

      I remember a programming contest where I had to sort a *huge* list of words into length order.

      My algorithm was by far the fastest. Most fools seemed to think that you need painfully slow O(n log n) time algotithms like QuickSort for sorting. :-)

    2. Re:Dijkstra's Algorithm: All-pairs, shortest-path by SkewlD00d · · Score: 2

      Major props. =) LSB radix sort is good too. O(1) insertion, O(1) search time is good.

      Does google.com use B-trees or radix?

      Wow, check this out... this could be adapted to the B-tree structure to make an awesome search engine!

      --
      The biggest trick the devil pulled was letting lawyers become politicians so they can write the laws.
  154. Awesome topic! by Anonymous Coward · · Score: 0

    My favorite algorithms?

    Genetic algorithm
    Monte Carlo
    Shear sort (? at least that's what I think it's called)

  155. Graph algorithms by pauljlucas · · Score: 1

    Reachability, closure, minimum spanning trees, finite state automata minimization, etc., have lots of uses and are some of my favorites.

    --
    If you reply, do so only to what I explicitly wrote. If I didn't write it, don't assume or infer it.
  156. I vote for "One Click Shopping" by LM741N · · Score: 2

    But I wasn't able to find that one in Netlib.

  157. My Private /. Webpage by litewoheat · · Score: 1
    function onFilterShashdotArticles(articles)
    {
    len = articles.length;
    for(i=0;i<len;i++)
    {
    if(articles[i].from == "Anonymous Coward" || articles[i].score < 1)
    {
    articles[i].filter = true;
    }
    }
    }
  158. #1 missed algorithm from 1950s by Anonymous Coward · · Score: 0

    Stack based function/procedure call/subroutine.

    1. Re:#1 missed algorithm from 1950s by MjDascombe · · Score: 1

      Do either of you even know what an algorythm is?

    2. Re:#1 missed algorithm from 1950s by Anonymous Coward · · Score: 0

      > Do either of you even know what an algorythm is?

      No, and you don't either.

  159. Heh...heh by waldoj · · Score: 3, Funny

    You know there's some guy still in the shower...

    OK, so it's 1987, and I'm 8 years old. My family has just gotten our first computer, an IBM PS/2 Model 30 -- one of the systems with BASIC in ROM. I''ve taken up writing in BASIC, and do so in most of my free time. Which, as an eight-year-old, is a considerably amount of time. I'd taught myself all about Boolean logic, loops, etc., etc.

    This is the part that I don't remember, probably because it's been obliterated by my family repeating the story so often. I've been in the shower for something like half an hour when my mother starts knocking on the door, wanting to know if I'm OK. I insist that I'm fine. This process is repeated for a while until they finally force me to get out, no doubt prune-like by this time. My mother asks me what in the world I've been doing in the shower for so long.

    I point to the directions on the back of the bottle and say, simply, "Wash. Rinse. Repeat."

    -Waldo Jaquith

  160. BSP trees by ncoder · · Score: 1
    BSP trees, for fast visibility testing.

    Hey, without them, bye bye Doom, Quake, Unreal, Half-life, etc...

    1. Re:BSP trees by The+Cookie+Monster · · Score: 2

      BSP trees don't give any visibility testing information. They provide a fast way of determining draw order, and ensure that there is always at least one correct draw order (an effect of the way surfaces are cut).

      AFAIK (I might have this bit all wrong, the Quake engine changed many times in development and I might not have got it right to begin with) With Quake, JC (John Carmak, not that other guy ;)) attached a list of visible polys in each leaf node of the BSP tree, but since which-polys-are-visible can change as you move around within the space defined by a leaf node, I suspect this has little to do with BSPs and he just used the BSP as a convenient structure to bolt the visibility info on to - it's already built, it's very fast to locate the leaf node volume you are in, the size of the volume will be smaller in more complex areas (where presumably the visibilty-list changes more often), the volume will always be convex with no walls running through it etc.

      But yeah, while I have yet to figure out exactly what people mean by "deep" (non-trivial and elegant?), BSP trees seem to be as classy as the other algorithms people are putting forward.

  161. My favorite algorithm... by wedg · · Score: 2

    ...is of course: BUBBLE SORT!

    Why? It's the only sort algorithm you can ALWAYS remember off the top of your head. (Besides, optimizations are for version 2.0).

    --
    Jake
    Dating: while( 1 ){ call_girl(); get_rejected(); drink_40(); } return 0;
    1. Re:My favorite algorithm... by DaCool42 · · Score: 1

      but bubble sort is one of the slower ways of sorting

      --

      ----
      All of whose base are belong to the what-now?
    2. Re:My favorite algorithm... by Anonymous Coward · · Score: 0

      but bubble sort is one of the slower ways of sorting

      That's why it's a joke man.

    3. Re:My favorite algorithm... by epine · · Score: 1


      Bubble sort gets a bad rap being the butt of every joke. Bubble sort was invented as the optimal sorting algorithm for a Turing machine.

  162. Elevator Awareness Algorithm by Anonymous+Squonk · · Score: 3, Funny
    If x=2 Then y=2 Else y=1

    Where x is the number of people in the elevator and y is the number of people who know for sure who farted.

  163. Nitpicks by greenrd · · Score: 1
    You have them mixed up. O(N) (which that algorithm is, technically, if you ignore the range) isn't constant time, it's linear time. O(1) is constant time.

    However, this is one case in which the "constant" factor (the range) is likely to outweigh the actual O(N) factor, so the O(N) notation is misleading. (The range isn't really constant of course - if you wanted to include that you could call it O(N+M)).

    Thanks for the algorithm though!

  164. Re:Theoretically interesting/Practically irrelevan by khuber · · Score: 1
    I disagree. Like the other guy in a second level post said, you need to know -when- to apply various common algorithms. Beyond that, programmers write algorithms all the time to carry out particular tasks. Just because I didn't write quick sort, doesn't make my algorithm unnecessary. Maybe there isn't a common algorithm for doing my task.

    Suppose I knew binary search was a fast way to find something in a sorted array, in O(log n). Of course I'd put all my strings in an array and use binary search, right? No, a better solution is probably to use a hash table, which is O(1). But by not understanding data structures and algorithms, you're not going to realize that problems can be transformed like that. It's the when all you have is a hammer, everything looks like a nail problem.

    I really believe that the world does not need more ignorant programmers producing junk code because they don't understand basic CS principles. And you don't need a CS degree either, just some fairly basic knowledge of algorithms, complexity, data structures, and when they apply.

    -Kevin

  165. Quine-McCluskey optimization method by WEFUNK · · Score: 1

    ...You may remember me from such algorithmic steps as "Expand my MinTerms and Don't Cares", "Group by Ones", "Compare the Pairs and Cover the Set", and "Find the Prime Implicants".

    ...oh wait that's the Troy-McClure method...

    Guess my prof didn't pronounce it quite right (or I wasn't quite listening).

    Great for minimizing the number of logic gates in a circuit, but we had to do it by hand for electrical engineering exams - so tedious! Certainly gave proof to why we now use computers for such mindless monkey-work.

    --
    My next sig will be ready soon, but friends can beat the rush!
  166. Re:My pick goes for RSA ... NOT! by Traa · · Score: 1

    recently it has been shown that RSA is not that great of an algorithm after all. New theories have shown that 1024-bit keys are not safe enough. The complexity of number factoring (though full of cool deep algorithms like the "Number Field Sieve") are not yet fully understood and seem to be easier computable then was previeously thought.

    Time will tell if this is going to lead to some form of world chaos becuase certain powers will be capable of cracking the worlds secrets (HTTPS, SSH, IPSec, S/MIME, PGP).

  167. Apparently by greenrd · · Score: 1
    B-W is used by the bzip2 compression program (which is used by kernel.org to compress kernel sources to a higher ratio than gzip does).

  168. My New Sorting Algorithm! by Enonu · · Score: 2

    while (!isSorted (array))
    array.swap (random (0, length), random (0, length));

  169. My Favorite Algorithm is... by fizban · · Score: 1

    ...the one that instructs my Mandrake 8.2 installation to show 25 minutes remaining for the last 15 minutes...

    --

    +1 Insightful, -1 Troll. What can I say, I'm an Insightful Troll.

  170. how about this one? by Anonymous Coward · · Score: 1, Funny

    1-click shopping

  171. hardware algorithms count? by Anonymous Coward · · Score: 0

    hmm... then again... are they really algorithms?
    heh -- to give a few:

    look-ahead carry for addition
    table - division (i forgot the name)
    branch predicate / out of order execution
    most of the hardware caching stuff (translation look-aside buffer, etc)

  172. What the heck is ROT13 ? by Rui+del-Negro · · Score: 1

    I'm guessing you don't know what ROT13 is. ROT13 is an "encrypting" algorithm used in e-mail and newsgroups that simply adds 13 to each letter (ie, it "rotates the alphabet by 180 degrees"). Most e-mail clients and news readers still have an "apply ROT13" option. I meant it as a joke, of course.

    1. Re:What the heck is ROT13 ? by JonWan · · Score: 0, Offtopic

      Yeah, I know you were making a joke. I was just fishing for an extra karma point, but alas the subject is too old for that. I need to learn to use ";-)" a little more. Anyone that doesn't know what ROT13 is shouldn't be posting on slashdot. ;-) I will get a -1 Offtopic now just to prove me wrong.

    2. Re:What the heck is ROT13 ? by Rui+del-Negro · · Score: 1

      Just say Microsoft is evil and CowboyNeal rules. That gets you two points minimum (usually for "Informative" and "Insightful", although it should actually be for "Redundant" and "Funny").

      If you want more, just add a signature that says "I'll probably be modded down as a Troll, but who cares?".

      And don't feel bad; no-one got my joke about recursive algorithms, either. There should be a way to add canned laughs to the posts.

  173. oldie but goodie by MikeyO · · Score: 1

    My all time favorite algorithm would have to be the first one i learned:

    10 print hello;

    20 goto 10

    1. Re:oldie but goodie by Ziviyr · · Score: 1

      My all time favorite algorithm would have to be the first one i learned:

      10 print hello;

      20 goto 10


      The computer I learned on would probably fill the screen with zeros if you did that on it. ;-)

      --

      Someone set us up the bomb, so shine we are!
  174. Two Phase Random Routing by panck · · Score: 1
    I like this algorithm because it's non-intuitive. I think we learned about this in Parallel Programming class.
    Basically, if you have a lot of network-linked boxes that you want to use for performing some parallel task, you run into network bottlenecks sometimes depending on how the network is structured. Esp. if you have a couple nodes which are doing a lot of communication, they can tie up a segment of the network, and all the other nodes get hurt.

    Two Phase Random Routing simply says, if you want to send data to some node, don't send it straight there. First send it to a random other node, who will forward it on.

    Amazingly, this fixes the problem.

    I don't remember if this was more effective for some networks/applications than others, but I thought it was cool.

    --
    "What thou shalt not, I shalt did!" -Bart Simpson
  175. Neural networks, fuzzy logic by Anonymous Coward · · Score: 0

    and two more: Prolog in Prolog and Lisp in Lisp

  176. What is a deep algorithm? by grytpype · · Score: 4, Insightful

    I think what Knuth means by "deep algorithm" is one that seems fundamental, something that tells us about the nature of reality, not necessarily something that is useful.

    --

    - Have a picture

  177. de Casteljau Algorithm by braeden · · Score: 1

    I nominate the de Casteljau algorithm for frame independent generation of curves and surfaces from control points by interpolation between the points.

    The algorithm sits on a mathematically rigorous foundation in affine (i.e. "frame independent" or "not based in a particular coordinate system") geometry, the study of which is quite fascinating (and complex) and highly recommended. (Book plug: Curves and Surfaces in Geometric Modeling by Jean Gallier. ISBN 1-55860-599-1. Heavy theory-- this is a math book. However, it directly applies to computer graphics.)

    Implementation of the algorithm and its extensions (such as the progressive version known as the de Boor algorithm) gives us polynomial and Bézier (spline) curves and surfaces and subdivision (which gives the CS implementor control over level of detail).

    Perhaps a reader can help elaborate on this and other algorithms in the curves and surfaces domain?

  178. Shor's Algorithm by Lank · · Score: 1

    How about Shor's algorithm? As useful quantum computing gets closer to reality every day, undoubtedly quantum algorithms such as Shor's will become increasingly more important.

    --
    Gotta get me one of these!
  179. Re:Patterns? Data Structures! by Anonymous Coward · · Score: 0
    Algorithm are for compilers, interpreters and parsers. Once it's done - no need to program it again.

    Patterns are the help when a lack of math in brains doesn't allow to verify the design choice - you just refer that the pattern works fine in "similar" situations.

    Data structures is what will drive upcoming programming. Welcome back to declarative languages!

  180. sorry but. by Anonymous Coward · · Score: 0

    I hate that aimbot algorithm in CS

  181. Dynamic nodes? by Sangui5 · · Score: 1

    How is it that the nodes are dynamically resizable? Once a node is created, it has a fixed size. If you use sentinals for head and tail they may need to change size, but not very often. Saying that the nodes are changing size during runtime is flat out wrong.

    And as for locking, a skiplist is fast enough that locking the whole thing isn't much of a penalty. Besides, if you're clever enough about it you can lock just a portion of the list and not the whole thing (lock top-down, and pre-decide how high the new node will be). True, that makes the code somewhat more complex, but that's nothing compared to any of the tree structures.

  182. fave algorithms by adminispheroid · · Score: 1
    Some biggies I use all the time, but haven't seen mentioned here, are Levenberg-Marquardt (sp?) (non-linear model fitting through chi-squared minimization) and Powell's direction set method (optimization). And biconjugate gradient methods for solving large sparse linear systems. Also we shouldn't take for granted Tchebychev methods, which are the magic behind fast accurate implementation of special functions like exp and sin.

    This may be a bit of a stretch -- but I have to mention the Beowulf algorithm: fill a room with cheap PCs, string together with scrounged network hardware, add Linux and MPI/PVM, and poof, you have a supercomputer.

    That original list of 10 certainly hit the war-horses -- Monte-Carlo, matrix decomposition, FFT -- without which life would be nasty, brutish, and short.

  183. Re:Theoretically interesting/Practically irrelevan by Evil+Pete · · Score: 2

    True. I agree 99%.

    The other 1% is for weird situations where you want some weird variation on a sort etc or its an algorithm that's in a library not ported to your platform/language so you have to actually code the algorithm. I did this once for some code that determined optimum paths through a network that was changing in real time while the object was moving. I found that the library versions of quicksort made the code too complicated, sorry I forget all the details, so I rewrote it ... took no time to do and worked as advertised. Also used graph algorithms in that too but had to modify them pretty severely.

    --
    Bitter and proud of it.
  184. Hindley-Milner type inference by Tom7 · · Score: 2

    Here's an important one that I bet will be overlooked: Hindley-Milner type inference. It's what makes programming in statically-typed languages require even less type annotations than languages like C!

    Don't forget that Milner got a turing award, in part for his work on type systems.

  185. Quicksort, Binary Traversal, Elevator or DDA by Anonymous Coward · · Score: 0

    In order of importance....

    (1) QuickSort (elegance)
    (2) Binary tree traversal (fundamental recursion)
    (3) Elevator Algorithms for scheduling disk I/O
    (4) DDA and Bresenham algorithms for 2D graphics
    (5) Various 3D algorithms

    The list of important algorithms just goes on and on. Many fields including compiler design, numerical methods, computer graphics and AI all have core algorithms of varying importance.

    Algorithms that we all use everyday are probably needed for graphics and operating sytems. Scheduling algorithms for operating systems and 2D and 3d rendering. Thats why I'm listing disk I/O scheduling and DDA as being next.

  186. Ah, but it DOES terminate. by Mr+Z · · Score: 1

    This is a BASIC program running on a real computer, and therefore it accepts inputs that are not explicitly written in the program.

    One of these inputs is the BREAK keystroke (exact key depends on the type of computer). That input causes the program to halt. Another is the power connection. If this is removed, the algorithm halts as well. ;-)

    It would seem that all real computers are subject to the latter constraint. Thus it would seem that all physically realizable programs (meaning, you can write them and run them on a machine, rather than just talk about them in broad terms) halt. Thus, in the grand scheme of things, they're ultimately eligible to be algorithms on this point due to artifacts of the implementation. :-)

    --Joe
  187. Did any of them actually test it? by Sycraft-fu · · Score: 1

    :)

    I had some fun at the expense of my TA in an intro CS course I took. It was a Java course (yuck) and the TA was a real condecending jerk (which is funny bacuse the professor was a nice guy). Now this course was for people with zero programming experence. I had a fair amount, but had to take it anyways because that is just how you did things in the CS major. The combination of that and the TA made me look for ways to make trouble. Soooooo...

    We had a homework assignment that required us to do some various thigns, I don't remember all of it, but one of them was to sort a pretty large list of things. The type of sort wasn't specified. I assume we were supposed to use qucik sort since we had learned it and the code for it was on the course page. However the professor told us that what counted with our programs was having clean, readable code and getting the job done, we could do things our own way to a large degree.

    So I wrote the most inefficient sort (short of something like this) I could think of. It was a recursive, bubble sort. It started at the beginning of the list and checked to see if the two items it was looking at were in order. If so, it incrimented it's counter, if not it switched the order. Then it called itself.

    As you can imagine this lead to rather a lot of memory usage, and apparently it ran like crap on the TA's computer since it was old, slow and didn't have a lot of memory to start with. I got a kick out of it since when talked to the professor about it, he decided I deserved full credit, since it DID work, just not optimally.

  188. 1 one-thousand, 2 one-thousand, .... by Mr+Z · · Score: 1
    Unfortunately, it took several hours.

    The guessing, the program, or both?

    --Joe
    1. Re:1 one-thousand, 2 one-thousand, .... by Eccles · · Score: 1

      The guessing, the program, or both?

      The original asking. He's got a stutter that would make Porky Pig envious...

      --
      Ooh, a sarcasm detector. Oh, that's a real useful invention.
    2. Re:1 one-thousand, 2 one-thousand, .... by Doppler00 · · Score: 1

      The counting. Actually, I'm sure most of the time is spent processing the PRINT statement. It is also an interpretted language so that further slows it down.

  189. Taylor rows? by Mr+Z · · Score: 1

    I think the translation you want is Taylor Series. Those infinitely long algebraic series for expressing transcendental functions line sine, cosine, etc. Right?

    --Joe
  190. Get into the rhythms of algorithms by Anonymous Coward · · Score: 0
    I still can't remember all 5 requirements according to Knuth, for an algorithm.
    [...]
    Just about anything you can define in a set of iterative (even if there is only 1 iteration) tasks can be construed as an algorythm.

    Heck, you can't even remember how to spell algorithm throughout a single Slashdot post.

  191. Will CS ever be a "science" by sielwolf · · Score: 1

    As one of my profs loves to put it "No real science has the word 'science' in it". Physics, Chemistry as compared to Social Science or Dropping Mad Science.

    And then there is Dijkstra's ubiquous quote/Attrition header "Computer Science is no more about computers than astronomy is about telescopes."

    I know this is OT but what would you call CS if you couldn't use the S? Computers? Algorithmics? Fingering Finite State Machines? Gasp, Information Technology? (BTW I think Technology is about as appropriate as Science is as a root noun).

    --
    What is music when you despise all sound?
    1. Re:Will CS ever be a "science" by thirty-seven · · Score: 1

      There is already another name for Computer Science - Informatics. According to the introduction of the Computer Science section of the University of Waterloo Undergrad Calendar, "Computer Science is centred around the study of information. It is concerned with the nature and properties of information, its structure and classification, its storage and retrieval, and the various types of processing to which it can be subjected. It is also concerned with the physical machines that perform these operations, with the elemental units of which these machines are composed, with the organization of these units into efficient information processing systems, and with the exploration of the limits of the abilities of these machines."

      --

      Atheism is a religion to the same extent that not collecting stamps is a hobby.

  192. And the winner is..... by Anonymous Coward · · Score: 0

    Garbage In =: Garbage Out

  193. The source of recursion is useful... by Jagasian · · Score: 2

    Therefore I nominate the least fixed-point of the lambda-calculus:
    \x(xx)

  194. What about BLAST? by dnaboy · · Score: 1
    For those who are unfamiliar with the DNA sequencing and analysis world, BLAST is an algorithm for finding similarities in DNA sequence. For example, I find a gene that codes for nerdiness, and sequence it. I can then run the sequence through BLAST and not only find out where in the genome (~3 billion G,C,A, and Ts) the sequence is, but also what other genes are similar or whether the same or a similar gene is in another species, such as mouse. Without a highly efficient homology algorithm, it's safe to say that the genome would be far from complete. I'm more of a bio guy than a CS guy, so I'm not really qualified to say whether it is as elegant as it appears from the outside, but hey, it got the job done either way

    If nothing else, 3 or 4 months ago Steve Jobs was glowing on stage at some conference touting how much the Mac kicks the butt of the PC in BLAST speed. No one, of course, bothered to mention that you'd be crazy to try to run BLAST with even a bacterial genome on a personal computer of any sort. It's efficient, but come on.

  195. Tree algorithms by Anonymous Coward · · Score: 1, Informative

    The most important algorithm I have used in the last 10 years.

    Threaded AVL trees.

    It is amazing how much code I have "fixed" or
    improved by dumping a:

    List with a sort function
    binary trees
    simple AVL trees
    loading data and then sorting it.

    This is the most underused yet best bang for the
    buck algorithm/data structure out there.

    I have used it for directed , undirected graphs,
    user interfaces, event handling, cacheing algorithms, data flow algorithms, searchs user information etc. The overhead is minimal and
    a known runtime is so important. The automatic
    reblancing has known points to make it thread
    safe and the ability to linear process through
    the tree makes it a replacement for any list were
    someone is searching for data.

    Leslie Donaldson

  196. BGP, IGRP, RIP, etc. by kyras · · Score: 2, Insightful

    BGP's routing algorithm and those of its its cousins and ancestors. Without this routing algorithm, you couldn't read /.

    --
    Tastes like burning! - Ralph Wiggum
  197. Learning algorithms by Hobbes_2100 · · Score: 1
    'nuff said. Well, not really. Some of these include:
    1. Genetic algorithms.
    2. Neural networks.
    3. Rule learning / Inductive logic programming algorithms.
    4. Reinforcement learning.
    5. Bayesian learning systems.
    Admittedly, many of these are actually "classes" of algorithms. There are fairly canonical examples of each though. It is also very important to note that all learning can be phrased as a search process. Hence, all searching techiniques [best first, depth first, A*, etc.] have a very important role in all of learning ... and in fact, in all of computer science. Herb Simon (love him or hate him) said that all AI is "heuristic search" (apologies if it was Newell that said this).

    Since I work with them everyday, I have to support them.

    Seriously though, they are very important (and for more things then just good game AI).

    Regards,
    Mark

  198. Berlinski's book by AutumnLeaf · · Score: 2, Informative

    Berlinski, author of "A Tour of the Calculus" (a damn good book), later wrote "The Advent of the Algorithm". It's on my to-read stack. I would think many slashdotters would be interested in reading it, and most slashdotters would be interested in reading the last comment on Amazon's review section. :-)

  199. Dictionary of Algorithms and Data Structures by sjpotenza · · Score: 1

    Check out a dictionary of algorithms and data structures at:

    http://www.nist.gov/dads

  200. The Adam Venus algorithm by Anonymous Coward · · Score: 0

    1: Find out about an outing you weren't invited to.

    2: Ingnore the fact you weren't invited for a reason and show up.

    3: Blow bad breath no everybody.

    4: Try and make intellectual conversation.

    5: Shout down anybody smarter than you who doesn't agree with your argument.

    6: See how many times you can fit Starwars into a conversation, regardless of topic.

    7: Goto step 1.

    1. Re:The Adam Venus algorithm by Anonymous Coward · · Score: 0

      This algorithm does not always work:
      1: Find out about an outing you weren't invited to.

      He failed to find out about the last outing he was not invited to.

      2: Ingnore the fact you weren't invited for a reason and show up.

      Will become 2:Bitch about not being told about outing that was not invited to, assume that there was no reason, merely people forgot.

      3: Blow bad breath no everybody.

      Blow much more bad breath on everybody to try and ensure that they do not forget you.

      4: Try and make intellectual conversation.

      Fail at this, remember that no one remembered to invite you, talk louder, and repeat yourself often

      5: Shout down anybody smarter than you who doesn't agree with your argument.

      Can be made into a much smaller and more effieicent statement: Shout down everybody, even those that agree with you. Including yourself.

      6: See how many times you can fit Starwars into a conversation, regardless of topic.

      And failing starwars some other movie(s). Make like movies are real.

      7: Goto step 1.

      or3.

  201. FFA by lonedfx · · Score: 2, Interesting

    My favorite algorithm, so simple yet so powerful, is the Fast Folding Algorithm, the one used by the seti@home client in your computer to detected repetitions in the signal, it's also used to detect unknown pulsars in space and I have experimented successfully with it on BPM detection in musical signals.

    Look it up, you'll like it.

    lone.

  202. Patterns are a fad by Anonymous Coward · · Score: 0

    Patterns are just a (now past) fad.

    Nothing new, just standardized terminology
    for all the constructs everybody was already
    using.

    Now that the terminology has been somewhat
    standardized, there is nothing more
    to be excited about wrt patterns.

  203. There is no such thing as "matured" science. by Anonymous Coward · · Score: 1, Insightful

    When science "matures", it becomes technology and engineering. Science, by definition, is the eternal process of charting the unknown, and re-examinating the known.

  204. If you want to try it out safely by roystgnr · · Score: 1

    Try limiting the number of processes it can spawn first: "ulimit -u 100" or something like that on bash. Then you start up top in another window to watch the results.

    I tried it on my machine (after syncing the disks) and didn't have to hard boot, but it took literally minutes to kill the damn thing off. Linux tries to split CPU time between processes rather than between users, it seems, and so one root login seems a thousandth as important the scheduler as 1000 spinning forkbombs.

    I don't suppose there's any kernel patches like the O(1) scheduler, but which implement a "be fair to multiple users" scheduler instead?

  205. traditional marriage algorithm? by ftdohist · · Score: 1

    this was one of the first that i learned - i used it just the other day to explain to some art grad students what an algorithm is.

  206. Favorite Algorithms by This+Is+Ridiculous · · Score: 1

    I haven't had much formal compsci training (yet) but I've always loved the way bottom-up parsers work. It's so counterintuitive at first glance, but when you finally grok it it's so simple.

    --
    Hey, you try to find an open nick these days!
  207. Simplest of the Simple by Cheese+Man · · Score: 1

    While this may not quite fit, my favorite implementation of an algorithm has to be strcpy in C, whose hart is:

    while (*src++ = *dst++);

    If you fully understand this single line, you've past the "beginner" stage...

    Also, a more-esoteric (though applicable) algorithm is the infamouse (and cool) swap of two variables without a third. Also a one-liner in C:

    a ^= b ^= a ^= b;

    or for the nit-picky:

    if (a != b) a ^= b ^= a ^= b;

    Anywho, these are the elegant examples that made me stick with Comp Sci long enough to learn RSA, et. al.

    1. Re:Simplest of the Simple by mikera · · Score: 2

      Don't think the "if (a!=b)" is a good idea in many cases.

      Isn't the other great advantage of your variable swapping algorithm to avoid a branch instruction which is costly on some architectures?

    2. Re:Simplest of the Simple by epine · · Score: 1


      The xor concept applied with bit masks leads to a very efficient method of performing an 8x8 bit block transpose in 3 passes over a pair of 32 bit integers (with shifting).

  208. this is funny? by Gumber · · Score: 2

    Gore didn't claim he invented the Internet, but lots of idiots claim he claimed to invent the Internet. So, where does that leave you?

    What Gore did claim was that he took initiative in creating the Internet, which he did. He drafted and sponsored key funding bills for NSFnet. The initiative put Internet access into the hands of univerisity students across all disciplines and, I think, proved that a large "Internet" could attract broad interest.

  209. Evolutionary Computation by GrEp · · Score: 2

    Evolutionary Computations. Defining a fitness metric for some problem and then searching the space using Darwin's principle of natural selection. It has done wonders for biological computing systems, and shows(has shown) promise for getting good solutions to many "hard" problems.

    --

    bash-2.04$
    bash-2.04$yes "Don't you hate dialup connections?"| write USERNAME
  210. Knapsack packing algorithms! by wdr1 · · Score: 1

    I mean really, what other algorithm also helps you move and pack a truck?

    -Bill

    --
    SlashSig Karma: Excellent (mostly affected by moderatio
  211. Euclid's Algorithm? by MattyT · · Score: 2

    How on Earth could Euclid's algorithm be the most important CS algorithm? I'll be the first to say Euclid's algorithm is really cool (and I believe I did actually, two days ago on an unrelated matter), but how useful is it?

    If we ignore for the moment the fact it isn't really CS at all, when was the last time you needed a GCD? Maybe I'm mathematically naive, but I can't think of one single use of a GCD. I'm sure there are plenty, but are there any outside of maths, physics, engineering, etc? Is there a general use of GCDs, like there is for say crypto or graphs?

    Does a GCD have a use in writing an operating system, or a programming language? When was the last time you saw a gcd function provided to a programmer in a standard library?

    1. Re:Euclid's Algorithm? by Gary+Yngve · · Score: 2

      ummm, most crypto involves taking gcds at some point or another.

    2. Re:Euclid's Algorithm? by mikera · · Score: 3, Interesting

      GCD is used for simplifying rational numbers. So it's used in pretty much any decent maths library.

      And rational numbers have a *lot* of uses. CAD, spreadsheets, high precision calculations, financial figures where rounding is unacceptable etc.

      I expect GCD also has implications for packing problems and complex scheduling algorithms where you need a quick check on which items are likely to "fit" together effectively. Anyone have experience of this?

  212. Depth-First search by TimoT · · Score: 1

    I'd argue that depth-first search is even more fundamental (topological sort is based on it). You can also compute strongly connected components using 2 DFS passes. Another fundamental graph algorithm would be the breadth-first search. I guess it depends on how you define fundamental, but I'd say a simple algorithm that is used to build simple algorithms.

  213. Unpublished by Anonymous Coward · · Score: 1, Interesting

    I have an unpublished "superalgorithm" in my desk drawer... Seriously, it is true.

    But, should I first try to patent it or should I publish it to get scientific credit?

    Cannot make up my mind. Please advice, with no nonsense arguments.

  214. Pessimal Algorithms and Simplexity Analysis by zook · · Score: 3, Interesting

    Pessimal Algorithms and Simplexity Analysis Read it---you'll like it. Find out the best algorithm to use if your boss makes you sort a list in Paris.

  215. Al Gore Rhythm by Alien+Being · · Score: 1

    chown -R gore /net

  216. Simple and Fast by ZeldorBlat · · Score: 1

    I've used this on several of my assignments in my algorithms class. And the beauty is, it solves any problem!

    Assume there exists an optimal solution O. Then we have:

    Opt()
    return O
    end

    Proof of Correctness:
    O is the optimal solution.
    The algorithm returns O.
    Therefore, the algorithm returns the optimal solution.

    Running Time Analysis:
    The algorithm returns O, which can be done in constant time. Therefore, the entire algorithm is O(1).

    This answer generally recieves minimum credit.

  217. Johnia Machine! by Tazzy531 · · Score: 2

    Johnia Machine is definitely the way to go...

    --


    _______________________________
    "I'm not Conceited...I'm just a realist..."
  218. i have an algortithm by Anonymous Coward · · Score: 0

    that factors arbitrarily large almost primes in constant time, unfortunately it is too long to be posted on /.

  219. Genetic Algorithms by sireenmalik · · Score: 1

    Why doesnot anyone mention GAs?

    I had heard a lot about GAs ( initial work by John Holland) before and was fascinated by the natural appeal of the idea: evoluation and "survuval of the fittest" strategy. Intrigued, i recently used a GA to solve a complex problem and was truly amazed by its efficiency. On the same kind of problems the classical solutions take longer(much longer) time.

    But GAs face their share of criticism. For example a strong solution/chromosome in a population can lead the entire population to follow(just like real life), or when after some iterations the difference between the best and worst solutions is not too much... the algorithm stops. The trick is then to have "Diversity" in the chromosome population( think about the Immigration schemes by the developed countries) and simultaneously allowing the solution to "Converge". It would be wrong not to mention R.B Holstein whose Selection Criteria are of trumendous value for handling both Diversity and Convergance at the same time.

    Given everything, i think GAs should be ranked in the top 10 algorithms.

    --


    Voltaire: God is dead.
    God: Voltaire is dead!
  220. Most important cs algorithm by Nicodemus713 · · Score: 1

    Without a doubt (illustrated in C):

    int main (char** argv)
    {
    printf("Hello World\n");
    exit(0);
    }

    Appearantly it is the fundemental building block upon which all programming languages are based.

    --
    Probability provides a way of summarizing the uncertainty that comes from our laziness and ignorance (Russell & Nor
  221. Here are my picks ... by Anonymous Coward · · Score: 1, Informative

    - A* algorithm (generic AI problem solving algorithm.)

    - Dijstra's minimum path (and other graph algothms.)

    - Risch algorithm (Maple uses this to integrate arbitrary expressions.)

    - Toom-Cook/FFT, Montgomery's algorithm (big number multiplies.)

    - Introspective sort. (Hybrid of Quick sort and Heap sort which gives great average and worst time complexity.)

    - Various pseudo-prime/factoring tests. There are a number of "random trial" algorithms that work unusually/unexpectedly well.

    - Karmarkar's algorithm (fast average and worst time complexity Linear program solver.)

    - Arithmetic encoding, PPMD, BWT (state of the art in compression algorithms which are pretty damn good.)

    - The DCT/iDCT algorithm (video/image compression.)

    - Peterson's Critical Section algorithm (great for multitasking.)

    - "Dynamic Programming".

    - Good Hashing algorithms.

  222. What about double bubble sort by Anonymous Coward · · Score: 0

    Which is nice for lists that are almost sorted anyway, e.g. positions of moving objects

  223. Pah by Anonymous Coward · · Score: 0

    get yourself a decent shower with JIT heating!

  224. I'd like an algorithm that... by Anonymous Coward · · Score: 0

    invents algorithms.

  225. Not funny you jerk by fungai · · Score: 1

    Who is this mister Knuth to say that computer science is not yet mature? If CS brought us UNIX, and even a CS student can program something as wonderful as Linux, then I say Computer Science is as mature as I want it to be, thank you very much. And to this Mr. Knuth I ask, do you even know anything about Computer Science?

    And an even more irrelevant side note... I once addressed Noam Chomsky as "Mr Chomsky", and when I realized my mistake and apologized he said "That's not a problem. Only my enemies call me "Professor Chomsky".

  226. Re: "throw the outOfShampooException" by Ocelot+Wreak · · Score: 2, Funny
    And you could also throw an exception on sham poo and instantiate some REAL poo!

    -wjc.

    --
    "I figure you're here 'cause you need some whacko who's willing to stick his finger in the fan. So who are we helping?
  227. Dear Lord, you're an arrogant one. by Anonymous Coward · · Score: 0

    I think the question dealt with algorithims, not "How can I get a job with Garin's shitty company?"

    Nor was the question "what does Garin think, and why should I care?" posed.

    Shut the hell up, asswipe.

  228. Patanjali's Yoga Sutra by adimanava · · Score: 1

    the algorithm par excellence to realise the Self, knowing which everything else is known!

  229. QuickSort vs. HeapSort by rpiaggio · · Score: 1
    I've seen QuickSort mentioned several times in the discussions. Do people still use QuickSort?

    Why not use HeapSort always, which has the same time complexity but lower space complexity (O(n))?

  230. The most important algorithms of all is... by Anonymous Coward · · Score: 0


    /* 99 bottles of beer in ansi c */

    #define MAXBEER (99)
    void chug(int beers);

    main()
    {
    register beers;

    for(beers = MAXBEER; beers; chug(beers--))
    puts("");

    puts("\nTime to buy more beer!\n");

    exit(0);
    }

    void chug(register beers)
    {
    char howmany[8], *s;

    s = beers != 1 ? "s" : "";
    printf("%d bottle%s of beer on the wall,\n", beers, s);
    printf("%d bottle%s of beeeeer . . . ,\n", beers, s);
    printf("Take one down, pass it around,\n");

    if(--beers) sprintf(howmany, "%d", beers); else strcpy(howmany, "No more");
    s = beers != 1 ? "s" : "";
    printf("%s bottle%s of beer on the wall.\n", howmany, s);
    }

  231. Hardcopy and (bent) Starplex diskettes by Ungrounded+Lightning · · Score: 2

    Sounds interesting. Got any documentation or source?

    I recently found the listings (after losing them for a couple years). They're a bit large to OCR.

    I've got two copies of the source on damaged Starplex(tm) diskettes - 8" floppies, NOT in CPM format, with bent envelopes.

    If you know anyone in the silicon valley area that can read Starplex diskettes or OCR 8 1/2 x (whatever printer paper was) fanfold listings, let me know. (Or if you're feeling like typing in 50ish pages of stuff... B-) )

    --
    Bantam Dominique roosters crow a four-note song. Once you've heard it as "Happy BIRTHday" you can't NOT hear it that way
  232. 1000? by bill_mcgonigle · · Score: 2

    Shouldn't it be the "Top 1024"?

    --
    My God, it's Full of Source!
    OUTSIDE_IP=$(dig +short my.ip @outsideip.net)