Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|cite|improve this question
up vote 6 down vote accepted

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.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.