# Which data structures are used for BFS and DFS of a graph?

Breadth First Search (BFS) and Depth First Search (DFS) are two different way of searching through data structures. BFS and DFS are algorithms that are primarily used for traversing or searching tree or graph data structures. DFS uses stack to search through the data structures, whereas BFS uses queue.

BFS is fairly simple to use as it doesn't need any data structures. It typically starts at the tree root or some arbitrary node of a graph, which is referred to as a 'search key'. It then explores the neighbor nodes first, before moving to the next level neighbors.

DFS is closely related to preorder traversal of a tree, which means that it first searches each node before its children. It starts searching at the tree root or some arbitrary node of a graph and explores as far as possible along each branch before backtracking and trying another route.

## Add new comment