0% found this document useful (0 votes)
7 views8 pages

AI notes

The document discusses searching algorithms in AI, which are methods to systematically explore possible solutions to problems. It outlines the concepts of problem-solving agents, search algorithm terminologies, properties of search algorithms, and classifies them into uninformed and informed types. Additionally, it details specific algorithms like Breadth-first Search and Depth-first Search, including their advantages, disadvantages, and complexities.

Uploaded by

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

AI notes

The document discusses searching algorithms in AI, which are methods to systematically explore possible solutions to problems. It outlines the concepts of problem-solving agents, search algorithm terminologies, properties of search algorithms, and classifies them into uninformed and informed types. Additionally, it details specific algorithms like Breadth-first Search and Depth-first Search, including their advantages, disadvantages, and complexities.

Uploaded by

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

Searching algorithm:

In AI, a searching algorithm is a method used to find a solution to a problem


by exploring possible paths in a systematic way. These algorithms are crucial
in AI for tasks like finding the shortest path, optimal solution, or best
outcome in a given scenario.

Problem-solving agents:
In Artificial Intelligence, 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. Problem-solving agents are the goal-based agents and
use atomic representation. In this topic, we will learn various
problem-solving search algorithms.

Search Algorithm Terminologies:


o Search: Searching’s a step by step procedure to solve a
search-problem in a given search space. A search problem
can have three main factors:

1. Search Space: Search space represents a set of


possible solutions, which a system may have.

2. Start State: It is a state from where agent begins the


search.

3. Goal test: It is a function which observe the current


state and returns whether the goal state is achieved or
not.

1
o Search tree: A tree representation of search problem is
called Search tree. The root of the search tree is the root
node which is corresponding to the initial state.

o Actions: It gives the description of all the available actions


to the agent.

o Transition model: A description of what each action do,


can be represented as a transition model.

o Path Cost: It is a function which assigns a numeric cost to


each path.

o Solution: It is an action sequence which leads from the start


node to the goal node.

o Optimal Solution: If a solution has the lowest cost among


all solutions.

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
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.

Uninformed/Blind Search:
The uninformed search does not contain any domain knowledge such as
closeness, the location of the goal. It operates in a brute-force way as it only
includes information about how to traverse the tree and how to identify leaf
and goal nodes. 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.It examines
each node of the tree until it achieves the goal node.

It can be divided into six main types:

3
o Breadth-first search

o Uniform cost search

o Depth-first search

o Depth limited search

o Iterative deepening depth-first search

o Bidirectional Search

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. Informed search
can solve much complex problem which could not be solved in another way.

An example of informed search algorithms is a traveling salesman problem.

1. Greedy Search

2. A* Search

3. Best first search

1. Breadth-first Search:
o 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.

4
o 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.

o The breadth-first search algorithm is an example of a


general-graph search algorithm.

o Breadth-first search implemented using FIFO queue data


structure.
Advantages:

o BFS will provide a solution if any solution exists.

o If there are more than one solutions for a given problem,


then BFS will provide the minimal solution which requires the
least number of steps.

o It also helps in finding the shortest path in goal state, since it


needs all nodes at the same hierarchical level before making
a move to nodes at lower levels.

o It is also very easy to comprehend with the help of this we


can assign the higher rank among path types.
Disadvantages:

o It requires lots of memory since each level of the tree must


be saved into memory to expand the next level.

o BFS needs lots of time if the solution is far away from the
root node.

o It can be very inefficient approach for searching through


deeply layered spaces, as it needs to thoroughly explore all
nodes at each level before moving on to the next

5
Example:

Time Complexity: Time Complexity of BFS algorithm can be obtained by the


number of nodes traversed in BFS until the shallowest Node. Where the d= depth
of shallowest solution and b is a node at every state.
T (b) = 1+b2+b3+.......+ bd= O (bd)
Space Complexity: Space complexity of BFS algorithm is given by the
Memory size of frontier which is O(bd).

Completeness: BFS is complete, which means if the shallowest goal node is


at some finite depth, then BFS will find a solution.

Optimality: BFS is optimal if path cost is a non-decreasing function of the


depth of the node.

6
2. Depth-first Search
o Depth-first search is a recursive algorithm for traversing a
tree or graph data structure.

o It is called the depth-first search because it starts from the


root node and follows each path to its greatest depth node
before moving to the next path.

o DFS uses a stack data structure for its implementation.

o The process of the DFS algorithm is similar to the BFS


algorithm.
Advantage:

o DFS requires very less memory as it only needs to store a


stack of the nodes on the path from root node to the current
node.

o It takes less time to reach to the goal node than BFS


algorithm (if it traverses in the right path).

o With the help of this we can stores the route which is being
tracked in memory to save time as it only needs to keep one
at a particular time.
Disadvantage:

o There is the possibility that many states keep re-occurring,


and there is no guarantee of finding the solution.

o DFS algorithm goes for deep down searching and sometime


it may go to the infinite loop.

o The de¬pth-first search (DFS) algorithm does not always find


the shorte¬st path to a solution.

7
Example

Completeness: DFS search algorithm is complete within finite state space as it will
expand every node within a limited search tree.
Time Complexity: Time complexity of DFS will be equivalent to the node
traversed by the algorithm. It is given by:
T(n)= 1+ n2+ n3 +………+ nm=O(nm)
Where, m= maximum depth of any node and this can be much larger than d
(Shallowest solution depth)
Space Complexity: DFS algorithm needs to store only single path from the root
node, hence space complexity of DFS is equivalent to the size of the fringe set,
which is O(bm).
Optimal: DFS search algorithm is non-optimal, as it may generate a large number
of steps or high cost to reach to the goal node.

You might also like