0% found this document useful (0 votes)
2 views31 pages

Search Algorithms in AI

The document discusses search algorithms in artificial intelligence, highlighting their role in problem-solving and categorizing them into uninformed and informed types. Key properties such as completeness, optimality, time complexity, and space complexity are outlined, along with specific algorithms like Breadth-First Search, Depth-First Search, Uniform Cost Search, and A* Search. It also provides examples of how these algorithms work, particularly in finding cost-effective paths in problem scenarios.

Uploaded by

Celin Narayanan
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)
2 views31 pages

Search Algorithms in AI

The document discusses search algorithms in artificial intelligence, highlighting their role in problem-solving and categorizing them into uninformed and informed types. Key properties such as completeness, optimality, time complexity, and space complexity are outlined, along with specific algorithms like Breadth-First Search, Depth-First Search, Uniform Cost Search, and A* Search. It also provides examples of how these algorithms work, particularly in finding cost-effective paths in problem scenarios.

Uploaded by

Celin Narayanan
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/ 31

Search Algorithms in AI

Problem Solving a problem


Problems are the issues which
come across any system. A solution
is needed to solve that particular
problem.
Problem Solving
In artificial intelligence, problems can be solved using
searching algorithms, evolutionary computations, knowledge
representations, etc.
Search techniques are universal problem-solving methods.
Rational agents or Problem-solving agents in AI mostly used
these search strategies or algorithms to solve a specific problem
and provide the best result.
Properties of Search Algorithms

• Completeness: A search algorithm is complete when it returns a


solution for any input if at least one solution exists for that
particular input.
• Optimality: If the solution deduced by the algorithm is the best
solution, i.e. it has the lowest path cost, then that solution is
considered as the optimal solution.
• Time Complexity: Time complexity is the time taken by an
algorithm to complete its task.
• Space Complexity: Space complexity is the maximum storage space
needed during the search operation.
Types of Search Algorithms
Uninformed/Blind Search

• does not contain any domain knowledge such


as closeness, the location of the goal
Breadth-First Search(BFS)
• In breadth-first search, the tree or the graph is traversed
breadthwise, i.e. it starts from a node called search key and
then explores all the neighbouring nodes of the search key at
that depth-first and then moves to the next level nodes.
• It is implemented using the queue data structure that works
on the concept of first in first out (FIFO).
• It is a complete algorithm as it returns a solution if a solution
exists.
• The time complexity is bd where b (branching factor) is the
average number of child nodes for any given node and d is
depth.
• The disadvantage - it requires a lot of memory space
because it has to store each level of nodes for the next one.
It may also check duplicate nodes.
Breadth-First Search(BFS)
Depth First Search(DFS)
• In depth-first search, the tree or the graph is
traversed depth-wise, i.e. it starts from a node called
search key and then explores all the nodes along the
branch then backtracks.
• It is implemented using a stack data structure that
works on the concept of last in first out (LIFO).
• The time complexity for breadth-first search is
bd where b (branching factor) is the average number
of child nodes for any given node and d is depth.
• It stores nodes linearly hence less space requirement.
• The major disadvantage is that this algorithm may go
in an infinite loop.
Depth First Search(DFS)
Uniform Cost Search

• In this algorithm, the cost comes into the


picture.
• There may be different paths to reach the
goal, so the path with the least cost
(cumulative sum of costs) is optimal.
• It traverses the path in the increasing
order of cost.
• It is similar to the breadth-first search if
the cost is the same for each transition.
Uniform Cost Search
Depth Limited Search Algorithm
• A depth limited search is close to DFS to some
extent. It can find the solution to the demerit of
DFS. The nodes at the depth may behave as if no
successor exists at the depth.
• Depth-limited search can be terminated in two
cases of failure:
– SFV: The Standard failure value which tells
that there is no solution to the problem.
– CFV: The Cutoff failure value tells that there is
no solution within the given depth.
• The DLS is efficient in memory space utilization.
• Time Complexity is expressed as O(bℓ).
• Space Complexity is expressed as O(b×ℓ).
• It has the demerit of incompleteness. It is
Iterative deepening depth-first Search
• This algorithm is a combination of BFS and DFS
searching techniques. It is iterative in nature. The
best depth is found using it.
• repeatedly applies depth-limited search with
increasing limits.
• It proves itself when the search space is large
and the depth is not known.
• This algorithm has one demerit, and it is that it
iterates all the previous steps.
• The algorithm is known to be complete only if the
branching factor is known r finite.
• Time Complexity is expressed as O(bd).
• Space Complexity is expressed as O(bd).
• This algorithm is optimal.
Bidirectional Search Algorithm
The Two way or Bidirectional search algorithm
executes in a way that it has to run two searches
simultaneously one in a forward direction and the
other in the backward direction.
The search will stop when the two simultaneous
searches intersect each other to find the goal node.
It is free to use any search algorithm discussed
above, like BFS, DFS, etc.
• Bidirectional search is quick and occupies less
memory.
• The implementation is difficult, and the goal node
should be known in advance to execute it.
• The Bidirectional Search algorithm is found to be
complete and optimal.
d
Informed Search Algorithms

• Informed search algorithms have domain


knowledge.
• It contains the problem description as well as
extra information like how far is the goal node.
• It is also called the Heuristic search
algorithm.
• It might not give the optimal solution always,
but it will definitely give a good solution in a
reasonable time.
• It can solve complex problems more easily
than uninformed.
Types of Informed Search
It is mainly of two types
• Greedy Best First Search
• A* Search
Greedy Best First Search
• In this algorithm, we expand the closest
node to the goal node.
• The closeness factor is roughly calculated
by heuristic function h(x).
• The node is expanded or explored when f
(n) = h (n).
• This algorithm is implemented through the
priority queue.
• It is not an optimal algorithm.
• It can get stuck in loops.
Greedy Best First Search

After A, It will start with B


because it has less cost than C,
then E because it has less cost
than D and then G2.
A* Search

• A* search is a combination of greedy


search and uniform cost search.
• In this algorithm, the total cost (heuristic)
which is denoted by f(x) is a sum of the
cost in uniform cost search denoted by
g(x) and cost of greedy search denoted by
h(x).
• f (x) = g (x) + h (x)
Given an initial state of a 8-puzzle problem and final state to
be reached-

• Find the most cost-effective path to


reach the final state from initial state
using A* Algorithm.
• Consider g(n) = Depth of node and h(n)
= Number of misplaced tiles.
• Consider the following graph-

The numbers written on edges represent the distance between the nodes.

The numbers written on nodes represent the heuristic value.

Find the most cost-effective path to reach from start state A to final state J
using A* Algorithm.
Step-01:

We start with node A.


Node B and Node F can be
reached from node A.

A* Algorithm calculates f(B) and


f(F).
f(B) = 6 + 8 = 14
f(F) = 3 + 6 = 9

Since f(F) < f(B), so it decides to


go to node F.

Path- A → F
Step-02:

Node G and Node H can be reached from


node F.

A* Algorithm calculates f(G) and f(H).


f(G) = (3+1) + 5 = 9
f(H) = (3+7) + 3 = 13

Since f(G) < f(H), so it decides to go to node


G.

Path- A → F → G
Step-03:

Node I can be reached from node G.

A* Algorithm calculates f(I).


f(I) = (3+1+3) + 1 = 8
It decides to go to node I.

Path- A → F → G → I
Step-04:

Node E, Node H and Node J can be reached from node I.

A* Algorithm calculates f(E), f(H) and f(J).


f(E) = (3+1+3+5) + 3 = 15
f(H) = (3+1+3+2) + 3 = 12
f(J) = (3+1+3+3) + 0 = 10

Since f(J) is least, so it decides to go to node J.

Path- A → F → G → I → J
This is the required shortest path from node A to node J.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy