I'm a student an I see the BFS Algorithm for graph exploration. I see the DFS algorithm too and this one is easily thinkable in a recursive mode. But is it possible for the BFS?
Thanks.
I'm a student an I see the BFS Algorithm for graph exploration. I see the DFS algorithm too and this one is easily thinkable in a recursive mode. But is it possible for the BFS?
Thanks.
You can always rewrite any iterative algorithm to a tail-recursive one -- in this case, by passing the entire work list as a parameter to a recursive call instead of jumping back to the top of the loop.
However, I don't think doing so would be particularly enlightening for breadth-first, except if you have to implement it in a language that has recursion but no explicit iteration constructs.