By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,948 Members | 1,230 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,948 IT Pros & Developers. It's quick & easy.

A flooding/echo algorithm in graphs/trees

P: 5
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?
Nov 13 '08 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 671
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.
Nov 13 '08 #2

Ganon11
Expert 2.5K+
P: 3,652
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.
Nov 13 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.