•

Check out our Community Blogs

Register and join over 40,000 other developers!

### Recent Blog Entries

• phi

I love this community !

# Iterative from recursive

recursive

### #1 Gerg? Magyar

Gerg? Magyar

CC Newcomer

• Member
• 22 posts

Posted 10 December 2011 - 10:07 PM

```
[COLOR="#800080"][B]public void[/B][/COLOR] bfs(){

printNode([COLOR="#800080"][B]this[/B][/COLOR].[COLOR="#0000FF"]rootNode[/COLOR]);

[COLOR="#0000FF"]rootNode[/COLOR].[COLOR="#0000FF"]visited[/COLOR]=[COLOR="#800080"][B]true[/B][/COLOR];

[COLOR="#800080"][B]while[/B][/COLOR](!q.isEmpty())

{

Node n=(Node)q.remove();

Node child=[COLOR="#800080"][B]null[/B][/COLOR];

[COLOR="#800080"][B]while[/B][/COLOR]((child=getUnvisitedChildNode(n))!=[COLOR="#800080"][B]null[/B][/COLOR])

{

child.[COLOR="#0000FF"]visited[/COLOR]=[COLOR="#800080"][B]true[/B][/COLOR];

printNode(child);

}

}

clearNodes();

}

```

• 0

### #2 lethalwire

lethalwire

while(false){ ... }

• Senior Member
• 766 posts
• Programming Language:C, Java, PHP, JavaScript
• Learning:PHP

Posted 12 December 2011 - 04:46 PM

Is there a question?
• 0

### Also tagged with one or more of these keywords: recursive

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download