as i rememeber and checked, that the usual way for traversing a tree or crawling the web breadth first (BFS) is by using a queue. Is there actually a way to implement it not using a queue?
views:
739answers:
2is there like a simple pseudo code some where that can implement BFS using recursion?
動靜能量
2009-05-13 03:44:33
I wonder about this too. How do you want to efficiently replace a queue by using the callstack?
Lucero
2009-06-29 14:01:47
+2
A:
You really should be using a queue, as its easier to implement. Also, a queue allows for multiple machines to work together (one queues site while another pops sites off of the queue to traverse).
The only other way I see to do this is by using recursion (much more difficult, and uses only marginally either more or less memory).
AlbertoPL
2009-05-13 03:30:27