BREADTH FIRST SEARCH(Artificial Intelligence)
PRESENTED BY:
MALAIKA
ZAINAB
HAJIRA
RUBAB
TAHIRA
PRESENTED TO:
MA’AM DUR-E-SHEHWARM-KTK
BREADTH FIRST SEARCH
(CONTENT)
• The Inventor
• Example
• Algorithm
• Time complexity
• Space complexity
• Queue in BFS
• Optimal
• Container of BFS
• Completeness
• Optimal
• Shallowest node
• Uninformed search technique
• Application
• Conclusion
M-KTK
INVENTOR OF BFS
• BFS and its application is finding
connected components of graphs
were originally invented in 1945 by
Konrad Zuse.
• His greatest achievement was the
world’s first programmable
computer.
• It was reinvented in 1959 by Edward
F. Moore, who used it to find the
shortest path out of a maze.
M-KTK
What Is Breadth First Search
• The Breadth First Search (BFS) is an algorithm for
traversing or searching tree or graph data
structures.
• It explores all the nodes at the present depth before
moving on to the nodes at the next depth level.
M-KTK
Example
Level 0
Level 1
Level 2
Level 3
M-KTK
BFS Algorithm
• Pick a node and
enqueue all its
adjacent nodes into a
queue.
Step 1
• Dequeue a node from
the queue, mark it as
visited and enqueue
all its adjacent nodes
into a queue.
Step 2 • Repeat this process
until the queue is
empty or you meet a
goal.
Step 3
Here are the steps for the BFS algorithm:
M-KTK
COMPLEXITY OF BREADTH FIRST
SEARCH
TIME COMPLEXITY:
• In the case of a graph, the
time complexity is
O(V+E) where V is the
number of vertexes and E
is the number of edges.
SPACE COMPLEXITY:
• Space complexity can be
expressed as O(|V|), where
|V| is the cardinality of the
set of vertices.
M-KTK
COMPLETENESS OF BREADTH
FIRST SEARCH
• Breadth-first search is complete, but Depth first search is not.
• Example:
• When applied to infinite graphs represented implicitly, BFS
will eventually find the goal state.
• But DFS may get lost in parts of the graph that have no
goal state and never return.
M-KTK
CONTAINER OF BFS AND DFS
• Choice of container used to store discovered vertices
while graph search…
oIf a queue is used as the container, we get breadth first
search.
oIf a stack is used as the container, we get depth first search.
M-KTK
QUEUES USED IN BFS
• Queues of BFS is operate on a FIFO principle
of item access.
• Let’s take a look at a picture representation of
a queue.
• When you enqueue, you are pushing the
element onto the array.
• When an element is dequeued, it is removed
from the queue, and the next element is then
ready to be dequeued.
Queue
Data Insert
Data out
M-KTK
IS BFS OPTIMAL?
• Breadth first search is optimal unlike depth first
search.
• If the path cost is a non-decreasing function of
d(depth). Normally, BFS is applied when all the
actions have the same cost. Optimal as in “produces
the optimal path”. Not “is the fastest algorithm
possible.
M-KTK
UNINFORMED SEARCH STRATEGY
• It is a simple search strategy where the root node is
expanded first, then covering all other successors of
the root node, further move to expand the next
level nodes and the search continues until the goal
node is not found.
• It is also called Blind search strategy.
M-KTK
Advantages and Disadvantages of BFS
ADVANTAGES
• Used to find the shortest path
between vertices
• Always finds optimal solutions.
• Finds the goal in less time.
DISADVANTAGES
• All of the connected vertices
must be stored in memory.
Which consumes more
memory.
M-KTK
APPLICATIONS
• GPS Navigation System: BFS is used to find all neighboring
locations.
• Broadcasting in Network: In networks, a broadcasted packet follows
BFS to reach all nodes.
• Garbage Collection: BFS is used in copying garbage collection using
Cheney’s algorithm.
• Cycle detection in undirected graph: In undirected graphs, either
BFS can be used to detect cycle.
• Ford-FulkersonAlgorithm: In this algorithm BFS is used to find the
maximum flow in a flow network.
M-KTK
APPLICATIONS
• Peer to Peer Networks: In peer to peer networks BFS 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.
• Path Finding: we can either use BFS to find if there is a path between
to vertices.
• It is also used in finding all nodes within one connected component.
M-KTK
CONCLUSION
BFS algorithm is a very important algorithm that traverses a graph and
uses a queue (FIFO) to remember to get the next vertex to start a
search, when a dead end occurs in any iteration.
BFS produces a so-called breadth-first tree and it is same as level order
traversing method.
BFS can be used to solve many problems in graph theory. It can also be
applied to solve of many real life for example GPS Navigation systems,
Computer Networks, Facebook structure, Web Crawlers for search
engine etc.
That is why a computer engineer must have a proper knowledge of BFS.
M-KTK
Thank you
M-KTK

Breadth first search signed

  • 1.
    BREADTH FIRST SEARCH(ArtificialIntelligence) PRESENTED BY: MALAIKA ZAINAB HAJIRA RUBAB TAHIRA PRESENTED TO: MA’AM DUR-E-SHEHWARM-KTK
  • 2.
    BREADTH FIRST SEARCH (CONTENT) •The Inventor • Example • Algorithm • Time complexity • Space complexity • Queue in BFS • Optimal • Container of BFS • Completeness • Optimal • Shallowest node • Uninformed search technique • Application • Conclusion M-KTK
  • 3.
    INVENTOR OF BFS •BFS and its application is finding connected components of graphs were originally invented in 1945 by Konrad Zuse. • His greatest achievement was the world’s first programmable computer. • It was reinvented in 1959 by Edward F. Moore, who used it to find the shortest path out of a maze. M-KTK
  • 4.
    What Is BreadthFirst Search • The Breadth First Search (BFS) is an algorithm for traversing or searching tree or graph data structures. • It explores all the nodes at the present depth before moving on to the nodes at the next depth level. M-KTK
  • 5.
  • 6.
    BFS Algorithm • Picka node and enqueue all its adjacent nodes into a queue. Step 1 • Dequeue a node from the queue, mark it as visited and enqueue all its adjacent nodes into a queue. Step 2 • Repeat this process until the queue is empty or you meet a goal. Step 3 Here are the steps for the BFS algorithm: M-KTK
  • 7.
    COMPLEXITY OF BREADTHFIRST SEARCH TIME COMPLEXITY: • In the case of a graph, the time complexity is O(V+E) where V is the number of vertexes and E is the number of edges. SPACE COMPLEXITY: • Space complexity can be expressed as O(|V|), where |V| is the cardinality of the set of vertices. M-KTK
  • 8.
    COMPLETENESS OF BREADTH FIRSTSEARCH • Breadth-first search is complete, but Depth first search is not. • Example: • When applied to infinite graphs represented implicitly, BFS will eventually find the goal state. • But DFS may get lost in parts of the graph that have no goal state and never return. M-KTK
  • 9.
    CONTAINER OF BFSAND DFS • Choice of container used to store discovered vertices while graph search… oIf a queue is used as the container, we get breadth first search. oIf a stack is used as the container, we get depth first search. M-KTK
  • 10.
    QUEUES USED INBFS • Queues of BFS is operate on a FIFO principle of item access. • Let’s take a look at a picture representation of a queue. • When you enqueue, you are pushing the element onto the array. • When an element is dequeued, it is removed from the queue, and the next element is then ready to be dequeued. Queue Data Insert Data out M-KTK
  • 11.
    IS BFS OPTIMAL? •Breadth first search is optimal unlike depth first search. • If the path cost is a non-decreasing function of d(depth). Normally, BFS is applied when all the actions have the same cost. Optimal as in “produces the optimal path”. Not “is the fastest algorithm possible. M-KTK
  • 12.
    UNINFORMED SEARCH STRATEGY •It is a simple search strategy where the root node is expanded first, then covering all other successors of the root node, further move to expand the next level nodes and the search continues until the goal node is not found. • It is also called Blind search strategy. M-KTK
  • 13.
    Advantages and Disadvantagesof BFS ADVANTAGES • Used to find the shortest path between vertices • Always finds optimal solutions. • Finds the goal in less time. DISADVANTAGES • All of the connected vertices must be stored in memory. Which consumes more memory. M-KTK
  • 14.
    APPLICATIONS • GPS NavigationSystem: BFS is used to find all neighboring locations. • Broadcasting in Network: In networks, a broadcasted packet follows BFS to reach all nodes. • Garbage Collection: BFS is used in copying garbage collection using Cheney’s algorithm. • Cycle detection in undirected graph: In undirected graphs, either BFS can be used to detect cycle. • Ford-FulkersonAlgorithm: In this algorithm BFS is used to find the maximum flow in a flow network. M-KTK
  • 15.
    APPLICATIONS • Peer toPeer Networks: In peer to peer networks BFS 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. • Path Finding: we can either use BFS to find if there is a path between to vertices. • It is also used in finding all nodes within one connected component. M-KTK
  • 16.
    CONCLUSION BFS algorithm isa very important algorithm that traverses a graph and uses a queue (FIFO) to remember to get the next vertex to start a search, when a dead end occurs in any iteration. BFS produces a so-called breadth-first tree and it is same as level order traversing method. BFS can be used to solve many problems in graph theory. It can also be applied to solve of many real life for example GPS Navigation systems, Computer Networks, Facebook structure, Web Crawlers for search engine etc. That is why a computer engineer must have a proper knowledge of BFS. M-KTK
  • 17.