Thursday, April 12, 2012

Best algorithm on checking a node in a tree path?

Suppose I have this tree :



           O-ROOT
/ \
O-A O-B
/ / \
O-A1 O-B1 O-B2


and I want to do this in C#:



1. Check every node starting from root (I think the best way is trought recursion?);
2. If I found a node with value = "Hello", return true and STOP the searching function;


Can you help me to make the best algorithm for doing it?





No comments:

Post a Comment