BFS: Difference between revisions
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 | ==Breadth-first search using queues== | ||
When doing BFS, use a queue. | When doing BFS, use a queue. The pseudocode looks like this: | ||
<pre> | |||
add root to queue | |||
while queue not empty: | |||
remove next item from queue | |||
perform search action on item | |||
add children queue | |||
</pre> | |||
==Flags== | |||
{{TreesFlag}} | |||
{{GraphsFlag}} | |||
[[Category:Trees]] | |||
[[Category:Binary Trees]] | |||
[[Category:Graphs]] | |||
[[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
| Trees Part of Computer Science Notes
Series on Data Structures Abstract data type: Trees/ADT Concrete implementations: Trees/LinkedTree · Trees/ArrayTree · SimpleTree
Tree Traversal Preorder traversal: Trees/Preorder Postorder traversal: Trees/Postorder In-Order traversal: Binary Trees/Inorder Breadth-First Search: BFS Breadth-First Traversal: BFT Depth-First Search: DFS Depth-First Traversal: DFT OOP Principles for Traversal: Tree Traversal/OOP · Tree Traversal/Traversal Method Template Tree operations: Trees/Operations Performance · Trees/Removal
Tree Applications Finding Minimum in Log N Time: Tree/LogN Min Search
Abstract data type: Binary Trees/ADT Concrete implementations: Binary Trees/LinkedBinTree · Binary Trees/ArrayBinTree Binary Trees/Cheat Sheet · Binary Trees/OOP · Binary Trees/Implementation Notes
|