cLive ;-) has asked for the wisdom of the Perl Monks concerning the following question:

Every now and then a question gets posted that throws up a great algorythm. Sometimes on seeing the algorythm, I see all sorts of uses for it for existing code of mine.

So, my question is, does anybody have a recommendation for a book/website/magazine/whatever that categorises and details algorythms, whether in Perl or just mathematically?

Examples that spring to mind are Schwartzian Transform and Text::Soundex (great for creating fuzzy indexing :).

Are there any good categorised lists with code/math to back them up floating around?

If so, got a favorite?

I've just been finding that knowing these things before I need them is becoming increasingly more useful...

cLive ;-)

  • Comment on Recommendations for general methods/algorythms anyone?

Replies are listed 'Best First'.
Re: Recommendations for general methods/algorythms anyone?
by diskcrash (Hermit) on May 22, 2001 at 09:54 UTC
    Dear cLive-

    An old classic is "Fundamental Algorithms - The Art of Computer Programming", by Donald Knuth Addison-Wesley Publishing, 1968. Other volumes came later. Many code examples using the MIX language are included. There is a particularly good section on tree traversal.

    If you are doing scientific/numerical work, try "Numerical Recipes in C" by Press, Flannery, Teukolsky and Vetterling- ISBN 0-521-35465-X. This book is a national treasure of mathematical algorithms and much code is included.

    Secant cosine tangent sine

    3 point 1 4 1 5 9

    logarithm, algorithm, I'm a wreck

    Another two years at old Caltech

    -diskcrash

      While Numerical Recipes is quite useful, I would hardly call it a "national treasure." Numerical Recipes gets recommended a lot because it is one of the more comprehensive references available on this subject but you should know that it's not perfect and has many flaws. The 'C' code in it is particularly horrendous. The Fortran version is somewhat better. The C code in Numerical Recipes reminds me of an old "mainframe hacker" who once told me "I can write Fortran in any language..."

      There's a page at NASA's Jet Propulsion Lab that's titled "Why not use Numerical Recipes." It's worth reading before jumping head first into the book and includes suggestions for alternatives to Numerical Recipes.

      That said, Numerical Recipes is certainly a useful starting place for numerical algorithms but remember that TMTOWTDI and this book only shows one way.

Re: Recommendations for general methods/algorythms anyone?
by the_slycer (Chaplain) on May 22, 2001 at 08:53 UTC
    Though not a list of algorithims per-se - you might look into Mastering Algorithims with Perl - from O'Reilly. Very interesting reading at the very least.
      I think Mastering Algorithims with Perl is a great read.
      Covers a lot of ground.

      There's no shortage of algorithim books geared towards C/C++ but not many for Perl.

      -Lee

      "To be civilized is to deny one's nature."
Re: Recommendations for general methods/algorythms anyone?
by busunsl (Vicar) on May 22, 2001 at 11:00 UTC
    Robert Sedgewick, Algorithms in <insert your favorite language here>.
    For the C++ version have a look here.
      Thanks,

      I think this is what I need :)

      (amazon reviews are particularly useful, particularly comments about file compression and cryptography :)

      cLive ;-)

Re: Recommendations for general methods/algorythms anyone?
by Odud (Pilgrim) on May 22, 2001 at 18:28 UTC
    Dictionary of Algorithms, Data Structures, and Problems is a fine way of spending an idle hour. Just a sample below to whet your appetite:
    minimum spanning tree (definition)

    Definition: A minimum-weight tree in a weighted graph which contains all of the graph's vertices.

    See also Kruskal's algorithm, Prim's algorithm, Steiner minimum tree, spanning tree.

    Note: A minimum spanning tree is a near-optimal solution to the traveling salesman problem. First find the minimum spanning tree. Then convert the tree to a path by traversing the tree, say by depth first search.
Re: Recommendations for general methods/algorythms anyone?
by Masem (Monsignor) on May 22, 2001 at 14:56 UTC
    If you need more numerically inclinded algo's, the book "Numerical Recipes in {C|Fortran|Pascal}" can be very useful, though it's in dire need of an update.


    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
Re: Recommendations for general methods/algorythms anyone?
by cLive ;-) (Prior) on May 22, 2001 at 12:01 UTC
    Wow, I've also improved my spelling here - I always thought it was 'y'. Now I know better :)

    cLive ;-)

Re: Recommendations for general methods/algorythms anyone?
by blue_cowdawg (Monsignor) on May 23, 2001 at 01:10 UTC

    Besides some of the books that I've seen others suggest, I'd like to suggest the three part series by Knuth, published by Addison Wesley. The three part series is

    1. Fundamental Algorithms
    2. SemiNumerical Algorithms
    3. Sorting and Searching
    As my father would say about those books "If you learn everything in those books you'll be one smart cookie!"

    
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Peter L. Berghold --- Peter@Berghold.Net
    "Those who fail to learn from history are condemned to repeat it."