College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
AI_Session 4 Uniformed search strategies.pptx
1. ARTIFICAL INTELLIGENCE
(R18 III(II Sem))
Department of computer science and
engineering (AI/ML)
Session 4
by
Asst.Prof.M.Gokilavani
VITS
2/23/2023 Department of CSE (AI/ML) 1
2. TEXTBOOK:
• Artificial Intelligence A modern Approach, Third
Edition, Stuart Russell and Peter Norvig, Pearson
Education.
REFERENCES:
• Artificial Intelligence, 3rd Edn, E. Rich and K.Knight
(TMH).
• Artificial Intelligence, 3rd Edn, Patrick Henny
Winston, Pearson Education.
• Artificial Intelligence, Shivani Goel, Pearson
Education.
• Artificial Intelligence and Expert Systems- Patterson,
Pearson Education.
2/23/2023 Department of CSE (AI/ML) 2
3. Topics covered in session 4
2/23/2023 Department of CSE (AI/ML) 3
• Problem solving by search-I: Introduction to AI, Intelligent
Agents.
• Problem solving by search-II: Problem solving agents,
searching for solutions
• Uniformed search strategies: BFS, Uniform cost search,
DFS, Iterative deepening Depth-first search, Bidirectional
search,
• Informed ( Heuristic) search strategies: Greedy best-first
search, A* search, Heuristic functions
• Beyond classical search: Hill- climbing Search, Simulated
annealing search, Local search in continuous spaces, Searching
with non-deterministic Actions, searching with partial
observations, online search agents and unknown environments.
4. Properties of Search Algorithms
• Following are the four essential properties of search algorithms to compare
the efficiency of these algorithms:
• Completeness: A search algorithm is said to be complete if it guarantees to
return a solution if at least any solution exists for any random input.
• Optimality: If a solution found for an algorithm is guaranteed to be the
best solution (lowest path cost) among all other solutions, then such a
solution for is said to be an optimal solution.
• Time Complexity: Time complexity is a measure of time for an algorithm
to complete its task.
• Space Complexity: It is the maximum storage space required at any point
during the search, as the complexity of the problem.
2/23/2023 4
Department of CSE (AI/ML)
5. Types of search algorithms
Based on the search problems we can classify the
search algorithms into
– uninformed (Blind search) search and
– informed search (Heuristic search) algorithms.
2/23/2023 5
Department of CSE (AI/ML)
7. Uninformed/Blind Search
•Uninformed search applies a way in which search tree is
searched without any information about the search space like
initial state operators and test for the goal, so it is also called
blind search.
•Don’t have any domain knowledge .
•It examines each node of the tree until it achieves the goal node.
It can be divided into five main types:
– Breadth-first search
– Uniform cost search
– Depth-first search
– Iterative deepening depth-first search
– Bidirectional Search
2/23/2023 7
Department of CSE (AI/ML)
8. Informed Search
• Informed search algorithms use domain knowledge. In an
informed search, problem information is available which
can guide the search.
• Informed search strategies can find a solution more
efficiently than an uninformed search strategy. Informed
search is also called a Heuristic search.
• A heuristic is a way which might not always be
guaranteed for best solutions but guaranteed to find a
good solution in reasonable time.
• An example of informed search algorithms is a traveling
salesman problem.
• Greedy Search
• A* Search
2/23/2023 8
Department of CSE (AI/ML)
9. Breadth-first Search
• Breadth-first search is the most common search
strategy for traversing a tree or graph. This
algorithm searches breadthwise in a tree or graph,
so it is called breadth-first search.
• BFS algorithm starts searching from the root node
of the tree and expands all successor node at the
current level before moving to nodes of next
level.
• The breadth-first search algorithm is an example
of a general-graph search algorithm.
• Breadth-first search implemented using FIFO
queue data structure.
2/23/2023 Department of CSE (AI/ML) 9
10. Algorithm
• Step 1: SET STATUS = 1 (ready state) for each node in
G
• Step 2: Enqueue the starting node A and set its
STATUS = 2 (waiting state)
• Step 3: Repeat Steps 4 and 5 until QUEUE is empty
• Step 4: Dequeue a node N. Process it and set its
STATUS = 3 (processed state).
• Step 5: Enqueue all the neighbours of N that are in the
ready state (whose STATUS = 1) and set
their STATUS = 2
(waiting state)
[END OF LOOP]
• Step 6: EXIT
2/23/2023 Department of CSE (AI/ML) 10
12. • In the example given below, there is a directed
graph having 7 vertices.
• In the above graph, minimum path 'P' can be
found by using the BFS that will start from
Node A and end at Node E.
• The algorithm uses two queues, namely
QUEUE1 and QUEUE2.
• QUEUE1 holds all the nodes that are to be
processed, while QUEUE2 holds all the nodes
that are processed and deleted fromQUEUE1.
2/23/2023 Department of CSE (AI/ML) 12
16. Applications of BFS algorithm
• BFS can be used to find the neighboring
locations from a given source location.
• BFS can be used in web crawlers to create web
page indexes.
• BFS is used to determine the shortest path and
minimum spanning tree.
2/23/2023 Department of CSE (AI/ML) 16
17. DFS (Depth First Search) algorithm
• It is a recursive algorithm to search all the
vertices of a tree data structure or a graph.
• The depth-first search (DFS) algorithm starts with
the initial node of graph G and goes deeper until
we find the goal node or the node with no
children.
• Because of the recursive nature, stack data
structure can be used to implement the DFS
algorithm.
• The process of implementing the DFS is similar
to the BFS algorithm.
2/23/2023 Department of CSE (AI/ML) 17
18. The step by step process to implement the DFS traversal
is given as follows -
• First, create a stack with the total number of vertices in
the graph.
• Now, choose any vertex as the starting point of
traversal, and push that vertex into the stack.
• After that, push a non-visited vertex (adjacent to the
vertex on the top of the stack) to the top of the stack.
• Now, repeat steps 3 and 4 until no vertices are left to
visit from the vertex on the stack's top.
• If no vertex is left, go back and pop a vertex from the
stack.
• Repeat steps 2, 3, and 4 until the stack is empty.
2/23/2023 Department of CSE (AI/ML) 18
19. Algorithm
• Step 1: SET STATUS = 1 (ready state) for each node in G
• Step 2: Push the starting node A on the stack and set its
STATUS = 2 (waiting state)
• Step 3: Repeat Steps 4 and 5 until STACK is empty
• Step 4: Pop the top node N. Process it and set its STATUS = 3
(processed state)
• Step 5: Push on the stack all the neighbors of N that are in the
ready state (whose STATUS = 1) and set their STATUS = 2
(waiting state)
• [END OF LOOP]
• Step 6: EXIT
2/23/2023 Department of CSE (AI/ML) 19
22. Applications of DFS
• DFS algorithm can be used to implement the
topological sorting.
• It can be used to find the paths between two
vertices.
• It can also be used to detect cycles in the graph.
• DFS algorithm is also used for one solution
puzzles.
• DFS is used to determine if a graph is bipartite or
not.
2/23/2023 Department of CSE (AI/ML) 22