Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Eliminating Recursive Tree Walking by using MJD-style Infinite Streams?

by jryan (Vicar)
on Jun 16, 2008 at 21:56 UTC ( [id://692389]=note: print w/replies, xml ) Need Help??


in reply to Re: Eliminating Recursive Tree Walking by using MJD-style Infinite Streams?
in thread Eliminating Recursive Tree Walking by using MJD-style Infinite Streams?

Thats definitely the root of my problem. I think your approach to an iterator might help though, I think I just need to figure-out how to integrate it with my code. One question before I try it out: what is more efficient memory-wise about your second approach than your first approach?

Replies are listed 'Best First'.
Re^3: Eliminating Recursive Tree Walking by using MJD-style Infinite Streams?
by Limbic~Region (Chancellor) on Jun 17, 2008 at 13:46 UTC
    jryan,
    Again, I am at the conference so I don't have the time to give you a proper response. The second one, which is more memory efficient, only requires as many nodes on the stack as the max depth of the tree. It does this by creating an iterator (one item) for the stack instead of a list of nodes (many) to visit. You then work through that iterator before moving on. This is a poor explanation - I know, but I won't be available to explain in detail until Thursday.

    Cheers - L~R

      In case you're curious,

      only requires as many nodes on the stack as the max depth of the tree.

      So does mine below.

      It does this by creating an iterator (one item) for the stack instead of a list of nodes (many) to visit.

      Mine doesn't wrap the array index in an iterator. I started making a version that did, but it was complicating the ability to return the path that led to the node (like the OP's) instead of just the node (like yours).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-03-28 19:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found