KEMBAR78
Adhit_presentation_Searching_Algorithm(BFS,DFS).pptx
Problem Solving By
Searching
-Adhit Upadhyay
-1203
Problem Solving By Searching
• Problem solving in AI is a systematic search through a range of
possible action in order to reach some predefined goal or the
solution.
• There are four general states in problem solving which are:
• Goal Formulation:
• A goal is a state that the agent is trying to reach
• Problem Formulation:
• This is the process of deciding what actions and states to consider, given goal
• Search Method:
• It determines possible sequence of actions and choose the best one.
• Execute:
• Provides the solution to the action.
Problem Formulation
• It involves deciding what actions and states to consider, given the
goal.
• A problem can be defined formally by 4 components :
• An initial state: From which agent start
• State description: Description of possible action available on agent. Also
called as successor function.
• Goal test: Determining the state is goal state or not.
• Path cost: Sum of cost of each path from initial to given state
State Space Representation
• The state space is defined as the directed graph with each node is a
state and arc represents the application of an operator transforming a
state to a successor state.
• A solution is path from the initial state to goal state consisting of
(S,s,O,G) where:
S = Set of state
s = start state
O = Operation (which helps to transfer state to it’s successor state)
G = Goal state
Search Techniques / Search Strategies
• There are two broad search strategies:
• Uninformed search methods:
• In this method, the order in which potential solution path are considered is arbitrary,
using no domain specific information to judge where the solution is likely to lie.
• Example: Breadth First Search, Depth First Search, Depth Limit Search, Bidirectional
Search, etc.
• Heuristically informed search methods:
• In this method, one uses domain- dependent (heuristic )information in order to search
the space more efficiently.
• Example: Greedy best first search, A* search, Hill climbing search, etc.
Performance Evaluation of Search Technique
• We can evaluate the performance of search techniques in four ways:
• Completeness : An algorithm is said to be complete if it definitely finds
solution to the problem, if exist.
• Time complexity: How long does it take to find a solution?
• Space complexity: How much space is used by the algorithm?
• Optimality: If a solution is found, is it guaranteed to be an optimal one ?
Example: Is it the one with minimum cost ?
A. Breadth First Search(BFS):
• It is an algorithm for traversing or searching tree or graph data structure.
• It stats with the tree root and explores all the neighbor nodes at the present
depth prior to moving on the nodes at the next depth level.
• It is implemented in FIFO queue in DSA.
• First move horizontally and visit all the nodes of the current layer
• Move to the next layer
• Do not generate as child node if the node is already parent to avoid more
loop.
Performance Measure of BFS
• Completeness: It always finds the solution if exist.
• Time complexity : Assume every state has b successor then,
• O(n) = O(
• Space complexity: If the goal node is at depth d then nodes of d depth are
expanded before traversing so space complexity is O( .
• Optimal: If all the path has same cost then optimal otherwise not.
Applications
• Social Networking Websites use BFS.
• In GPS navigation system.
• Broadcasting in network.
B. Depth First Search (DFS):
• It is another method for search or traversing tree or graph data structures.
• This algorithm stats at root node and explores as far as possible along each
branch before backtracking.
• It is implemented in LIFO stack.
• The main strategy of DFS is to explore deeper into the graph whenever
possible.
• When all the edge have been explored, the search backtracks until it reaches
an unexplored neighbor.
• This process continues until all the vertices are reached without forming any
loop.
Performance Measure of DFS
• Completeness: It does not find the solution in all cases.
• Time complexity : Let m be the maximum depth then,
• O(n) = O(
• Space complexity: Need to store single node so,
• = (b + b + b + b + ….) * m time
• = O (bm)
• Optimal: It gives optimal solution than BFS but it does not give optimal
solution if the foal node is in right child of level 2 or 3 of graph having m = 10
or more.
Applications
• Detecting cycle in the graph
• Path Finding
• Topological sorting
Adhit_presentation_Searching_Algorithm(BFS,DFS).pptx

Adhit_presentation_Searching_Algorithm(BFS,DFS).pptx

  • 1.
  • 2.
    Problem Solving BySearching • Problem solving in AI is a systematic search through a range of possible action in order to reach some predefined goal or the solution. • There are four general states in problem solving which are: • Goal Formulation: • A goal is a state that the agent is trying to reach • Problem Formulation: • This is the process of deciding what actions and states to consider, given goal • Search Method: • It determines possible sequence of actions and choose the best one. • Execute: • Provides the solution to the action.
  • 3.
    Problem Formulation • Itinvolves deciding what actions and states to consider, given the goal. • A problem can be defined formally by 4 components : • An initial state: From which agent start • State description: Description of possible action available on agent. Also called as successor function. • Goal test: Determining the state is goal state or not. • Path cost: Sum of cost of each path from initial to given state
  • 4.
    State Space Representation •The state space is defined as the directed graph with each node is a state and arc represents the application of an operator transforming a state to a successor state. • A solution is path from the initial state to goal state consisting of (S,s,O,G) where: S = Set of state s = start state O = Operation (which helps to transfer state to it’s successor state) G = Goal state
  • 5.
    Search Techniques /Search Strategies • There are two broad search strategies: • Uninformed search methods: • In this method, the order in which potential solution path are considered is arbitrary, using no domain specific information to judge where the solution is likely to lie. • Example: Breadth First Search, Depth First Search, Depth Limit Search, Bidirectional Search, etc. • Heuristically informed search methods: • In this method, one uses domain- dependent (heuristic )information in order to search the space more efficiently. • Example: Greedy best first search, A* search, Hill climbing search, etc.
  • 6.
    Performance Evaluation ofSearch Technique • We can evaluate the performance of search techniques in four ways: • Completeness : An algorithm is said to be complete if it definitely finds solution to the problem, if exist. • Time complexity: How long does it take to find a solution? • Space complexity: How much space is used by the algorithm? • Optimality: If a solution is found, is it guaranteed to be an optimal one ? Example: Is it the one with minimum cost ?
  • 7.
    A. Breadth FirstSearch(BFS): • It is an algorithm for traversing or searching tree or graph data structure. • It stats with the tree root and explores all the neighbor nodes at the present depth prior to moving on the nodes at the next depth level. • It is implemented in FIFO queue in DSA. • First move horizontally and visit all the nodes of the current layer • Move to the next layer • Do not generate as child node if the node is already parent to avoid more loop.
  • 8.
    Performance Measure ofBFS • Completeness: It always finds the solution if exist. • Time complexity : Assume every state has b successor then, • O(n) = O( • Space complexity: If the goal node is at depth d then nodes of d depth are expanded before traversing so space complexity is O( . • Optimal: If all the path has same cost then optimal otherwise not.
  • 9.
    Applications • Social NetworkingWebsites use BFS. • In GPS navigation system. • Broadcasting in network.
  • 10.
    B. Depth FirstSearch (DFS): • It is another method for search or traversing tree or graph data structures. • This algorithm stats at root node and explores as far as possible along each branch before backtracking. • It is implemented in LIFO stack. • The main strategy of DFS is to explore deeper into the graph whenever possible. • When all the edge have been explored, the search backtracks until it reaches an unexplored neighbor. • This process continues until all the vertices are reached without forming any loop.
  • 11.
    Performance Measure ofDFS • Completeness: It does not find the solution in all cases. • Time complexity : Let m be the maximum depth then, • O(n) = O( • Space complexity: Need to store single node so, • = (b + b + b + b + ….) * m time • = O (bm) • Optimal: It gives optimal solution than BFS but it does not give optimal solution if the foal node is in right child of level 2 or 3 of graph having m = 10 or more.
  • 12.
    Applications • Detecting cyclein the graph • Path Finding • Topological sorting