Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this presentation? Why not share!

- BFS by jyothimonc 3795 views
- Breadth first search by Vignesh Prasanna 2482 views
- Graphs bfs dfs by Jaya Gautam 8328 views
- Breadth First Search Algorithm by Cagatay Yuksel 2231 views
- Bfs and dfs in data structure by Ankit Kumar Singh 2578 views
- Depth first search and breadth firs... by Kawsar Hamid Sumon 966 views

No Downloads

Total views

2,581

On SlideShare

0

From Embeds

0

Number of Embeds

2

Shares

0

Downloads

143

Comments

0

Likes

1

No embeds

No notes for slide

- 1. Breadth First-Search
- 2. Lecturer: Miss Sana Rizwan
- 3. Presented By
- 4. Definition Breadth-first search (BFS) start from the root node and explores all the neighbouring nodes. Then for each of those nearest nodes, it explores their neighbour nodes, and so on, until it finds the goal.
- 5. Applications Breadth-first search can be used to solve many problems in graph theory, for example: • • • Finding all nodes within one connected components. Finding the shortest path between two nodes u and v . Testing a graph for bipartiteness.
- 6. States • Undiscovered--white colour • Discovered but not fully explored-grey colour • Fully explored.-black colour
- 7. How It Works? • • • • • Pick a source vertex S to start. Find (or discover) the vertices that are adjacent to S. Pick each child of S in turn and discover their vertices adjacent to that child. Done when all children have been discovered and examined. The breadth-first search uses a FIFO queue.
- 8. Step # 1
- 9. Step # 2
- 10. Step # 3
- 11. Step # 4
- 12. Step # 5
- 13. Step # 6
- 14. Step # 7
- 15. Step # 8
- 16. Step # 9
- 17. Algorithm Algorithm BFS(s ) 1. color all the vertices white 2. initialize an empty queue Q 3. for each neighbor v of s 4. insert v in Q ; color [v ] = grey 5. output s ; color [s ] = black 6. while Q is not empty 7. u = top of Q ; remove u from Q 8. for each neighbor v of u 9. if color [v ] = white 10. insert v in Q ; color [v ] = grey 11. output u; color [u] = black

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment