Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^13: Finding All Paths From a Graph From a Given Source and End Node

by LanX (Saint)
on Nov 02, 2010 at 20:23 UTC ( [id://869084]=note: print w/replies, xml ) Need Help??


in reply to Re^12: Finding All Paths From a Graph From a Given Source and End Node
in thread Finding All Paths From a Graph From a Given Source and End Node

yep just try to imagine what linearizing and short circuiting could achieve.

Cheers Rolf

  • Comment on Re^13: Finding All Paths From a Graph From a Given Source and End Node

Replies are listed 'Best First'.
Re^14: Finding All Paths From a Graph From a Given Source and End Node
by BrowserUk (Patriarch) on Nov 02, 2010 at 20:33 UTC
    try to imagine what linearizing and short circuiting could achieve.

    Hm. Seeing's believing :) But I'm not really sure what you mean by "linearizing" in this context?

    If you mean brute-forcing the recursion to iteration using manual stack handling, that often works out more costly than the recusion it is trying to eliminate.

    If the recursion can be eliminated through tail-recursion, that's very effective in languages that support it. (Properly; goto \&recurse is usually slower).

    But I'm pretty sure this can't be written to be tail-recursive.

      just intelligent looping, no need for tail-recursion.

      Any recursion can be linearized.

      Pushing and popping the @path array and/or %seen is all you need as a stack.

      But I'm too lazy to do neversaints homework! :)

      Cheers Rolf

        If I thought that this was homework, I wouldn't be doing it either!

        But neversaint has a long history of posting deeply involved genomic programming tasks. And he is always more than willing to do his part in cleaning up and generalising what we post for his use.

        I'm not sure whether he's making a fortune off of the help he gets here, or is on a research pittance furthering the science for the benefit of all human-kind. Nor do I much care.

        He presents interesting problems, and I enjoy trying to solve them. It's far better than a cross-word or sudoku. (Besides, I wrote solvers for both of those years ago. Now if only I could get the computer to buy the papers and scan them in, they'd get used :)

        Come to that. If neversaint's Perl/CS lecturer is presenting problems like these as "homework", he is either a brilliant lecturer with very gifted students; or a sadistic bastard.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://869084]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-24 06:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found