Skip to content

Instantly share code, notes, and snippets.

@t81lal
Created May 29, 2015 19:14
Show Gist options
  • Save t81lal/2f37b9edaed99ae85766 to your computer and use it in GitHub Desktop.
Save t81lal/2f37b9edaed99ae85766 to your computer and use it in GitHub Desktop.
Breadth first
private NumberNode firstNumber(AbstractNode node) {
if(node == null || node.children() == 0)
return null;
for(AbstractNode n : node) {
if(n instanceof NumberNode)
return (NumberNode) n;
}
for(AbstractNode n : node) {
NumberNode n1 = firstNumber(n);
if(n1 != null)
return n1;
}
return null;
}
@t81lal
Copy link
Author

t81lal commented May 29, 2015

Is this right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment