0% found this document useful (0 votes)
23 views

Aiml Seminor757

The document discusses breadth first search (BFS), an algorithm for traversing or searching tree or graph data structures. BFS starts at the root node and explores all neighbor nodes at the present depth before moving to the next depth level. It explains how BFS works, its time and memory requirements, applications, advantages, and provides a conclusion on BFS being an important graph traversal algorithm.

Uploaded by

sumatksumatk5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Aiml Seminor757

The document discusses breadth first search (BFS), an algorithm for traversing or searching tree or graph data structures. BFS starts at the root node and explores all neighbor nodes at the present depth before moving to the next depth level. It explains how BFS works, its time and memory requirements, applications, advantages, and provides a conclusion on BFS being an important graph traversal algorithm.

Uploaded by

sumatksumatk5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Breadth First Search

Presented By : Suma T K
Sujatha
Sudeep
Sumanth
What is Breadth first search(BFS)?

• Breadth-first search is an algorithm for traversing or searching


Tree or Graph data structures.
• It starts at the tree root or some arbitrary node of a graph,
sometimes referred to as ‘search key’ and explores all of the
neighbour nodes at the present depth prior to moving on to the
nodes at the next depth level.
Inventor of BFS
BFS and its application in finding connected
components of graphs were originally invented in
1945 by Konrad Zuse.

He was a German Civil Engineer, inventor and


computer pioneer. His greatest achiement was the
world’s first programmable computer.
• How BFS Works
1. Start by selecting a starting vertex and enqueue it into a queue.
2. Mark the starting vertex as visited.
3. Repeat the following steps until the queue is empty:
1. Dequeue a vertex from the queue.
2. Visit the dequeued vertex.
3. Enqueue all the adjacent vertices of the dequeued vertex that have not
been visited.
4. Mark the visited vertices as visited.
4. Continue this process until all the vertices have been visited.
Breadth First Search Algorithm
* The root node is expanded first and then all the successors of the nodes * are expended next, and their
successors and so on.
* In general, all the nodes at a given depth are expanded in the search three before any node at next level are
expanded.
* Mark any node as start(initial) node
* explore and traverse un-visited nodes adjacent to starting node
*mark nodes as completed and move to next adjacent and un-visited node.
Completeness : yes (if b is finite),the shallowest solution
is returned
Time complexity : b+b2+b3+….+bd=O(bd)
time requirement is still a major factor
space complexity : O(bd) (keeps every node in memory)
space is the bigger problem (more than time)
optimal : yes if step costs are all identical or path cost is a
nondecreasing function of the depth of the node
TIME AND MEMORY REQUIREMENTS

It depends on the implementation and the data structure used.


The time complexity is O(V+E)
• Where v is number of vertices
• E is the number of edges in the graph
 BFS visits each vertex and edge once.
 First, the memory requirements are a bigger problem for breadth-first search
than is the execution time.
 One might wait 13 days for the solution to an important problem with search
depth 12.
 The second lesson is that time is still a major factor. If your problem has a
solution at depth 16.
 Then it will take about 350 years for breadth-first search to find it.
 In general, exponential-complexity search problems cannot be solved by
uninformed methods for any but the smallest instances.
Applications of breadth first search:
 Peer-to-Peer Networks: In Peer-to-Peer Networks like BitTorrent, Breadth First Search
is used to find all neighbor nodes.
 Social Networking Websites: In social networks, we can find people within a given
distance ‘k’ from a person using Breadth First Search till ‘k’ levels.
 GPS Navigation systems: Breadth First Search is used to find all neighboring locations.
 Broadcasting in Network: In networks, a broadcasted packet follows Breadth First
Search to reach all nodes.
 AI: In AI, BFS is used in traversing a game tree to find the best move.earch to reach all
nodes.
Advantages of Breadth First Search:

• BFS will never get trapped exploring the useful path forever.
• If there is a solution, BFS will definitely find it.
• If there is more than one solution then BFS can find the minimal one that requires
less number of steps.
• Low storage requirement – linear with depth.
• Easily programmable.
Conclusion:
• Breadth first search (BFS) algorithm is a very important algorithm that transverse a graph in a
breadthward motion and uses a queue (FIFO method) to remember to get the next vertex to start a
search, when a dead end occurs in any iteration.

• Breadth-first search is a widely used graph traversal algorithm that can be used to explore a graph
efficiently.

• It can be implemented using a queue or a deque to store the nodes to be explored, and a data structure to
keep track of the visited nodes.

• That is why , as a computer engineer we should have a proper knowledge of Breadth first search(BFS)

You might also like