0% found this document useful (0 votes)
38 views9 pages

Uninformed and Informed Search Algorithms

hjgj

Uploaded by

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

Uninformed and Informed Search Algorithms

hjgj

Uploaded by

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

UNINFORMED SEARCH ALGORITHMS

The uninformed search algorithm does not have any domain knowledge such as closeness, location
of the goal state, etc. it behaves in a brute-force way.
It only knows the information about how to traverse the given tree and how to find the goal state.
This algorithm is also known as the Blind search algorithm or Brute -Force algorithm.
The uninformed search strategies are of six types.
They are-
 Breadth-first search
 Depth-first search
 Depth-limited search
 Iterative deepening depth-first search
 Bidirectional search
 Uniform cost search
Let’s discuss these six strategies one by one.
1. Breadth-first search
It is of the most common search strategies. It generally starts from the root node and examines the
neighbor nodes and then moves to the next level. It uses First-in First-out (FIFO) strategy as it
gives the shortest path to achieving the solution.
BFS is used where the given problem is very small and space complexity is not considered.
Now, consider the following tree.

Here, let’s take node A as the start state and node F as the goal state.
The BFS algorithm starts with the start state and then goes to the next level and visits the node
until it reaches the goal state.
In this example, it starts from A and then travel to the next level and visits B and C and then
travel to the next level and visits D, E, F and G. Here, the goal state is defined as F. So, the
traversal will stop at F.

The path of traversal is:


A —-> B —-> C —-> D —-> E —-> F
Advantages of BFS
 BFS will never be trapped in any unwanted nodes.

1
 If the graph has more than one solution, then BFS will return the optimal solution which
provides the shortest path.
Disadvantages of BFS
 BFS stores all the nodes in the current level and then go to the next level. It requires a lot of
memory to store the nodes.
 BFS takes more time
to reach the goal state which is far away.

2. Depth-first search
The depth-first search uses Last-in, First-out (LIFO) strategy and hence it can be implemented by
using stack. DFS uses backtracking. That is, it starts from the initial state and explores each path to
its greatest depth before it moves to the next path.
DFS will follow
Root node —-> Left node —-> Right node
Now, consider the same example tree mentioned above.
Here, it starts from the start state A and then travels to B and then it goes to D. After reaching
D, it backtracks to B. B is already visited, hence it goes to the next depth E and then backtracks to
B. as it is already visited, it goes back to A. A is already visited. So, it goes to C and then to F. F is
our goal state and it stops there.

The path of traversal is:


A —-> B —-> D —-> E —-> C —-> F
Advantages of DFS
 It takes lesser memory as compared to BFS.
 The time complexity is lesser when compared to BFS.
 DFS does not require much more search.
Disadvantages of DFS
 DFS does not always guarantee to give a solution.
 As DFS goes deep down, it may get trapped in an infinite loop.

3. Depth-limited search
Depth-limited works similarly to depth-first search. The difference here is that depth-limited
search has a pre-defined limit up to which it can traverse the nodes. Depth-limited search solves
one of the drawbacks of DFS as it does not go to an infinite path.
DLS ends its traversal if any of the following conditions exits.
Standard Failure
It denotes that the given problem does not have any solutions.
Cut off Failure Value
It indicates that there is no solution for the problem within the given limit.
Now, consider the same example.
Let’s take A as the start node and C as the goal state and limit as 1.
The traversal first starts with node A and then goes to the next level 1 and the goal state C is there.
It stops the traversal.

2
The path of traversal is:
A —-> C
If we give C as the goal node and the limit as 0, the algorithm will not return any path as the goal
node is not available within the given limit.
If we give the goal node as F and limit as 2, the path will be A, C, F.
Advantages of DLS
 It takes lesser memory when compared to other search techniques.
Disadvantages of DLS
 DLS may not offer an optimal solution if the problem has more than one solution.
 DLS also encounters incompleteness.

4. Iterative deepening depth-first search


Iterative deepening depth-first search is a combination of depth-first search and breadth-first
search. IDDFS find the best depth limit by gradually adding the limit until the defined goal state is
reached.
Let me try to explain this with the same example tree.
Consider, A as the start node and E as the goal node. Let the maximum depth be 2.
The algorithm starts
with A and goes to the next level and searches for E. If not found, it goes to
the next level and finds E.

The path of traversal is


A —-> B —-> E
Advantages of DLS
 It takes lesser memory when compared to other search techniques.
Disadvantages of DLS
 DLS may not offer an optimal solution if the problem has more than one solution.
 DLS also encounters incompleteness.

4. Iterative deepening depth-first search


3
Iterative deepening depth-first search is a combination of depth-first search and breadth-first
search. IDDFS find the best depth limit by gradually adding the limit until the defined goal state is
reached.
Let me try to explain this with the same example tree.
Consider, A as the start node and E as the goal node. Let the maximum depth be 2.
The algorithm starts
with A and goes to the next level and searches for E. If not found, it goes to
the next level and finds E.

The path of traversal is


A —-> B —-> E
Advantages of IDDFS
 IDDFS has the advantages of both BFS and DFS.
 It offers fast search and uses memory efficiently.
Disadvantages of IDDFS
 It does all the works
of the previous stage again and again.

5. Bidirectional search
The bidirectional search algorithm is completely different from all other search strategies. It
executes two simultaneous searches called forward-search and backwards-search and reaches the
goal state. Here, the graph is divided into two smaller sub-graphs. In one graph, the search is
started from the initial start state and in the other graph, the search is started from the goal state.
When these two nodes intersect each other, the search will be terminated.
Bidirectional search requires both start and goal start to be well defined and the branching factor to
be the same in the two directions.
Consider the below graph.

Here, the start state is E and the goal state is G. In one sub-graph, the search starts from E and in
the other, the search starts from G. E will go to B and then A. G will go to C and then A. Here,
both the traversal meets at A
and hence the traversal ends.

4
The path of traversal is
E —-> B —-> A —-> C —-> G
Advantages of bidirectional search
 This algorithm searches the graph fast.
 It requires less memory to complete its action.
Disadvantages of bidirectional search
 The goal state should be pre-defined.
 The graph is quite
difficult to implement.

6. Uniform cost search


Uniform cost search is considered the best search algorithm for a weighted graph or graph with
costs. It searches the graph by giving maximum priority to the lowest cumulative cost. Uniform
cost search can be implemented using a priority queue.
Consider the below
graph where each node has a pre-defined cost.

Here, S is the start node and G is the goal node.


From S, G can be reached in the following ways.
S, A, E, F, G -> 19
S, B, E, F, G -> 18
S, B, D, F, G -> 19
S, C, D, F, G -> 23
Here, the path with the least cost is S, B, E, F, G.

5
Advantages of UCS
 This algorithm is optimal as the selection of paths is based on the lowest cost.
Disadvantages of UCS
 The algorithm does not consider how many steps it goes to reach the lowest path. This may
result in an infinite loop also.
Comparison of various uninformed search algorithms
Now, let me compare the six different uninformed search strategies based on the time complexity.
Optimalit
Algorithm Time Space Complete
y
Breadth First O(b^d) O(b^d) Yes Yes
Depth First O(b^m) O(bm) No No
Depth Limited O(b^l) O(bl) No No
Iterative Deepening O(b^d) O(bd) Yes Yes
Bidirectional O(b^(d/2)) O(b^(d/2)) Yes Yes
Uniform Cost O(bl+floor(C*/epsilon)) O(bl+floor9C*/epsilon)) Yes Yes
This is all about uninformed search algorithms.

6
INFORMED SEARCH ALGORITHMS
The informed search algorithm is also called heuristic search or directed search. In contrast to
uninformed search algorithms, informed search algorithms require details such as distance to reach
the goal, steps to reach the goal, cost of the paths which makes this algorithm more efficient.
Here, the goal state can be achieved by using the heuristic function.
The heuristic function is used to achieve the goal state with the lowest cost possible. This function
estimates how close a state is to the goal.
Let’s discuss some of the informed search strategies.

1. Greedy best-first search algorithm


Greedy best-first search uses the properties of both depth-first search and breadth-first search.
Greedy best-first search traverses the node by selecting the path which appears best at the moment.
The closest path is selected by using the heuristic function.
Consider the below
graph with the heuristic values.

Here, A is the start node and H is the goal node.


Greedy best-first search first starts with A and then examines the next neighbour B and C. Here,
the heuristics of B is 12 and C is 4. The best path at the moment is C and hence it goes to C. From
C, it explores the neighbours F and G. the heuristics of F is 8 and G is 2. Hence it goes to G. From
G, it goes to H whose heuristic is 0 which is also our goal state.

The path of traversal is


A —-> C —-> G —-> H
Advantages of UCS
 This algorithm is optimal as the selection of paths is based on the lowest cost.
Disadvantages of UCS
 The algorithm does not consider how many steps it goes to reach the lowest path. This may
result in an infinite loop also.

7
Comparison of various uninformed search algorithms
Now, let me compare the six different uninformed search strategies based on the time complexity.
Optimalit
Algorithm Time Space Complete
y
Breadth First O(b^d) O(b^d) Yes Yes
Depth First O(b^m) O(bm) No No
Depth Limited O(b^l) O(bl) No No
Iterative Deepening O(b^d) O(bd) Yes Yes
Bidirectional O(b^(d/2)) O(b^(d/2)) Yes Yes
Uniform Cost O(bl+floor(C*/epsilon)) O(bl+floor9C*/epsilon)) Yes Yes

This is all about uninformed search algorithms.


Let’s take a look at informed search algorithms.

Informed search algorithms


The informed search algorithm is also called heuristic search or directed search. In contrast to
uninformed search algorithms, informed search algorithms require details such as distance to reach
the goal, steps to reach the goal, cost of the paths which makes this algorithm more efficient.
Here, the goal state can be achieved by using the heuristic function.
The heuristic function is used to achieve the goal state with the lowest cost possible. This function
estimates how close a state is to the goal.
Let’s discuss some of the informed search strategies.

1. Greedy best-first search algorithm


Greedy best-first search uses the properties of both depth-first search and breadth-first search.
Greedy best-first search traverses the node by selecting the path which appears best at the moment.
The closest path is selected by using the heuristic function.
Consider the below
graph with the heuristic values.

Here, A is the start node and H is the goal node.


Greedy best-first search first starts with A and then examines the next neighbour B and C. Here,
the heuristics of B is 12 and C is 4. The best path at the moment is C and hence it goes to C. From
C, it explores the neighbours F and G. the heuristics of F is 8 and G is 2. Hence it goes to G. From
G, it goes to H whose heuristic is 0 which is also our goal state.

8
The path of traversal is
A —-> C —-> G —-> H
The time complexity of the A* search is O(b^d) where b is the branching factor.
Advantages of A* search algorithm
 This algorithm is best when compared with other algorithms.
 This algorithm can be used to solve very complex problems also it is an optimal one.
Disadvantages of A* search algorithm
 The A* search is based on heuristics and cost. It may not produce the shortest path.
 The usage of memory is more as it keeps all the nodes in the memory.
Now, let’s compare uninformed and informed search strategies.

Comparison of uninformed and informed search algorithms


Uninformed search is also known as blind search whereas informed search is also called heuristics
search. Uniformed search does not require much information. Informed search requires domain-
specific details. Compared to uninformed search, informed search strategies are more efficient and
the time complexity of uninformed search strategies is more. Informed search handles the problem
better than blind search.

End Notes
Search algorithms are used in games, stored databases, virtual search spaces, quantum computers,
and so on. In this article, we have discussed some of the important search strategies and how to use
them to solve the problems in AI
and this is not the end. There are several algorithms to solve any problem. Nowadays, AI is
growing rapidly and applies to many real-life problems.

You might also like