This is the basic recursion algorithm for a tree in Java.
public Object recurse(Object obj){
Object result = obj;
boolean found = result == baseCase ||
result == baseCase2
if (found)
return result;
else {
ObjectList list = getObjectChildren(result);
for (Object child : list){
result = recurse(child);
found = result == baseCase ||
result == baseCase2;
if(found)
break;
}
)
return result;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment