From charlesreid1

No edit summary
Line 1: Line 1:
==Breadth-first search using queues==
==Breadth-first search using queues==


When doing BFS, use a queue.  
When doing BFS, use a queue. The pseudocode looks like this:
 
Add the root node to the queue.
 
While the queue is not empty:
 
remove item from queue,
 
perform action on item,
 
add children to queue.


<pre>
add root to queue
while queue not empty:
    remove next item from queue
    perform search action on item
    add children queue
</pre>


==Flags==
==Flags==

Revision as of 20:12, 11 June 2017

Breadth-first search using queues

When doing BFS, use a queue. The pseudocode looks like this:

add root to queue
while queue not empty:
    remove next item from queue
    perform search action on item
    add children queue

Flags