From charlesreid1

(Created page with "==Breadth-first search - queues== When doing BFS, use a queue. Add the root node to the queue. While the queue is not empty: remove item from queue, perform action on i...")
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Breadth-first search - 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.
<pre>
add root to queue
while queue not empty:
    remove next item from queue
    perform search action on item
    add children queue
</pre>


While the queue is not empty:
==Flags==


remove item from queue,
{{TreesFlag}}
{{GraphsFlag}}


perform action on item,
[[Category:Trees]]
[[Category:Binary Trees]]
[[Category:Graphs]]


add children to queue.
[[Category:Traversal]]
[[Category:Algorithms]]
[[Category:Queues]]

Latest revision as of 15:51, 7 September 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