A flooding/echo algorithm in graphs/trees

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • orzeech
    New Member
    • Nov 2008
    • 5

    A flooding/echo algorithm in graphs/trees

    He everyone!

    My question is quite simple: is there an algorithm that does exactly what's shown on this picture:


    I thought about using BFS or IDDFS that "backtrack" after reaching all the leaves of the graph. Is there a better way to compute this algorithm?
  • oler1s
    Recognized Expert Contributor
    • Aug 2007
    • 671

    #2
    You're not really searching for anything here. You just need a recursive echo. Are you guaranteed two or less children for every node. Actually, it's irrelevant, but it does simplify the code you write.

    In any case, it's a recursive algorithm. If you're having trouble, work your way up. Start with a tree with only one node. Then a node with one child. Then two children. And keep expanding the tree. You should be able to formulate a proper recursive algorithm. It's nothing special.

    Comment

    • Ganon11
      Recognized Expert Specialist
      • Oct 2006
      • 3651

      #3
      It looks like the algorithm just marks a node with how many children it has, which shouldn't even take that much work in the recursive function. I could be wrong, though, the example provided was fairly simple.

      Comment

      Working...