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

Re: Depth First Search

by Corion (Patriarch)
on Aug 09, 2016 at 17:41 UTC ( [id://1169424]=note: print w/replies, xml ) Need Help??


in reply to Depth First Search

Using multiple threads makes very little sense for a depth-first search, as both tree traversal approaches (depth-first, breadth-first) impose a fixed order on when the nodes are visited.

Maybe you can show us some examples of how you think the nodes should be visited if multiple threads are iterating over a tree.

Usually, the "best" algorithmic approach is to have a worker pool of trees threads and as long as there are multiple nodes at the current level of the current tree and workers available in the pool, spawn send off a worker thread for every child node until the pool is exhausted and process the remaining nodes using the current thread.

Update: Corrected some words, as per ikegamis reply

Replies are listed 'Best First'.
Re^2: Depth First Search
by ikegami (Patriarch) on Aug 09, 2016 at 18:51 UTC

    The whole point of worker pools is the avoid having to spawn off threads after processing has started.

      The whole point of worker pools is the avoid having to spawn off threads after processing has started.

      Yeah, so obviously by "spawn" Corion means, give the worker a job to do

Log In?
Username:
Password:

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

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

    No recent polls found