0% found this document useful (0 votes)
5 views

8. uninformed search algorithm

The document discusses various uninformed search strategies, including breadth-first search, depth-first search, depth-limited search, iterative deepening depth-first search, and bidirectional search. Each strategy is evaluated based on its completeness, optimality, time complexity, and space complexity, highlighting their advantages and disadvantages. The document emphasizes the trade-offs between memory usage and search efficiency in different algorithms.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

8. uninformed search algorithm

The document discusses various uninformed search strategies, including breadth-first search, depth-first search, depth-limited search, iterative deepening depth-first search, and bidirectional search. Each strategy is evaluated based on its completeness, optimality, time complexity, and space complexity, highlighting their advantages and disadvantages. The document emphasizes the trade-offs between memory usage and search efficiency in different algorithms.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Uninformed Search

Strategies
Introduction
● An uninformed search algorithm is given no clue about how close a state is
to the goal(s).
● For example, consider our agent in Arad with the goal of reaching
Bucharest.
● An uninformed agent with no knowledge of Romanian geography has no
clue whether going to Zerind or Sibiu is a better first step.
● In contrast, an informed agent who knows the location of each city knows
that Sibiu is much closer to Bucharest and thus more likely to be on the
shortest path.
Breadth - first search

•Expands the root node first, then its successors, level by level.

•Ensures completeness, even in infinite state spaces.

•Can be implemented using BEST-FIRST-SEARCH with f(n) = node depth.

•Uses a FIFO queue, making it more efficient than a priority queue.

•Early goal testing improves efficiency.


Breadth-first search on a simple binary tree

● The memory requirements are a bigger problem for breadth-first search than the
execution time.

● Exponential-complexity search problems cannot be solved by uninformed search for


any but the smallest instances.
Breadth - first search (cont…)
Time & Space Complexity:

•O(b^d), where b = branching factor, d = depth.

•Memory usage grows exponentially, making BFS infeasible for deep searches.

•Example:
•b = 10, depth = 10 → Requires 10 TB memory.
•Depth = 14 → 3.5 years even with infinite memory.

•Best for finding shortest paths but limited by memory constraints.


Dijkstra's algorithm or uniform-cost search

•Used when actions have different costs.

•Expands nodes in order of lowest path cost instead of uniform depth.

•Can be implemented using BEST-FIRST-SEARCH with PATH-COST as the


evaluation function.

•Ensures cost-optimality, always finding the lowest-cost path first.


Finding the shortest path from Sibiu to
Bucharest
•Expand Rimnicu Vilcea (cost 80)
→ Add Pitesti (cost 177).

•Expand Fagaras (cost 99) → Add


Bucharest (cost 310).

•Expand Pitesti → Add Bucharest


(cost 278) (lower cost).

•Algorithm picks the cheapest


path (278) as the final solution.
Key Properties

•Complete: Always finds a solution if one exists.

•Optimal: Always finds the lowest-cost path.

•Complexity: O(b^(1 + C*/ε)), potentially higher than BFS.


Key Properties(cont…)

● The complexity of uniform-cost search is characterized in terms of


○ C*, the cost of the optimal solution, and
○ €, a lower bound on the cost of each action, with € > 0.

● Then the algorithm’s worst-case time and space complexity is ,


which can be much greater than b^d

● When all action costs are equal, uniform-cost search is similar to breadth-
first search.
Depth-first Search

● Depth-first search is a recursive algorithm for traversing a tree or graph data


structure.

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

● DFS uses a stack data structure for its implementation.

● Backtracking is an algorithm technique for finding all possible solutions


using recursion.
Advantage

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

● It takes less time to reach to the goal node than BFS algorithm (if it traverses
in the right path).

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

● There is the possibility that many states keep re-occurring, and there is no
guarantee of finding the solution.

● DFS algorithm goes for deep down searching and sometime it may go to the
infinite loop.

● The depth-first search (DFS) algorithm does not always find the shortest
path to a solution.
Example

It will follow the order as:

Root node--->Left node ----> right node.


Depth-first Search(cont…)

● 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:

● 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).
Depth-Limited Search Algorithm

● A depth-limited search algorithm is similar to depth-first


search with a predetermined limit.

● Depth-limited search can solve the drawback of the infinite


path in the Depth-first search.

● In this algorithm, the node at the depth limit will treat as it


has no successor nodes further.
Depth-Limited Search Algorithm(cont…)

Depth-limited search can be terminated with two Conditions of


failure:

• Standard failure value: It indicates that problem does not


have any solution.

• Cutoff failure value: It defines no solution for the problem


within a given depth limit.
Depth-Limited Search Algorithm(Advantages)

• Depth-Limited Search will restrict the search depth of the


tree, thus, the algorithm will require fewer memory resources.

• When there is a leaf node depth which is as large as the


highest level allowed, do not describe its children, and
then discard it from the stack.

• Depth-Limited Search does not explain the infinite loops


which can arise in classical when there are cycles in graph of
cities.
Depth-Limited Search Algorithm(Disadvantages)

• Depth-limited search also has a disadvantage of


incompleteness.

• It may not be optimal if the problem has more than one


solution.

• The effectiveness of the Depth-Limited Search (DLS)


algorithm is largely dependent on the depth limit specified. If
the depth limit is set too low, the algorithm may fail to find
the solution altogether.
Depth-Limited Search Algorithm(cont…)

● Completeness: DLS search algorithm is complete if the


solution is above the depth-limit.

● Time Complexity: Time complexity of DLS algorithm


isO(bℓ) where b is the branching factor of the search tree, and
l is the depth limit.

● Space Complexity: Space complexity of DLS algorithm is


O(b×ℓ) where b is the branching factor of the search tree,
and l is the depth limit.
Iterative deepening depth-first Search
● The iterative deepening algorithm is a combination of DFS and
BFS algorithms. This search algorithm finds out the best depth
limit and does it by gradually increasing the limit until a goal is
found.
● This algorithm performs depth-first search up to a certain "depth
limit", and it keeps increasing the depth limit after each iteration
until the goal node is found.
● This Search algorithm combines the benefits of Breadth-first
search's fast search and depth-first search's memory
efficiency.
● The iterative search algorithm is useful uninformed search when
search space is large, and depth of goal node is unknown.
Iterative deepening depth-first Search
Steps for Iterative deepening depth first search algorithm:
• Set the depth limit to 0.
• Perform DFS to the depth limit.
• If the goal state is found, return it.
• If the goal state is not found and the maximum depth has not
been reached, increment the depth limit and repeat steps 2-4.
• If the goal state is not found and the maximum depth has
been reached, terminate the search and return failure.
Iterative deepening depth-first Search(Advantages)

• It combines the benefits of BFS and DFS search algorithm in terms


of fast search and memory efficiency.

• It is a type of complete algorithm, and the meaning of this is it will


always find a solution if one exists.

• The Iterative Deepening Depth-First Search (IDDFS) algorithm uses


less memory compared to Breadth-First Search (BFS) because it
only stores the current path in memory, rather than the entire
search tree.
Iterative deepening depth-first
Search(Disadvantages)
• The main drawback of IDDFS is that it repeats all the work of
the previous phase.
1'st Iteration-----> A
2'nd Iteration----> A, B, C
3'rd Iteration------>A, B, D, E, C, F, G
4'th Iteration------>A, B, D, H, I, E, C, F, K, G
In the fourth iteration, the algorithm will find the
goal node.
Iterative deepening depth-first Search

Completeness:
● This algorithm is complete is if the branching factor is finite.
Time Complexity:
● Let's suppose b is the branching factor and depth is d then the worst-case time
complexity is O(bd).

Space Complexity:
● The space complexity of IDDFS will be O(bd).
Optimal:
● IDDFS algorithm is optimal if path cost is a non-decreasing function of the
depth of the node.
Bidirectional Search Algorithm

● Bidirectional search algorithm runs two simultaneous searches, one form


initial state called as forward-search and other from goal node called as
backward-search, to find the goal node.

● Bidirectional search replaces one single search graph with two small
subgraphs in which one starts the search from an initial vertex and other
starts from goal vertex. The search stops when these two graphs intersect
each other.

● Bidirectional search can use search techniques such as BFS, DFS, DLS, etc.
Advantages

● Bidirectional search is fast.

● Bidirectional search requires less memory

● The graph can be extremely helpful when it is very large in size and there is
no way to make it smaller. In such cases, using this tool becomes particularly
useful.

● The cost of expanding nodes can be high in certain cases. In such scenarios,
using this approach can help reduce the number of nodes that need to be
expanded.
Disadvantages

● Implementation of the bidirectional search tree is difficult.

● In bidirectional search, one should know the goal state in advance.

● Finding an efficient way to check if a match exists between search trees can
be tricky, which can increase the time it takes to complete the task.
Bidirectional Search Algorithm
▪This algorithm divides one graph/tree
into two sub-graphs.
▪ It starts traversing from node 1 in
the forward direction and starts from
goal node 16 in the backward
direction.
▪The algorithm terminates at node 9
where two searches meet.
Bidirectional Search Algorithm
Completeness: Bidirectional Search is complete if we use BFS in both
searches.

Time Complexity: Time complexity of bidirectional search using BFS is


O(bd).

Space Complexity: Space complexity of bidirectional search is O(bd).

Optimal: Bidirectional search is Optimal.


Evaluation of search algorithms. b is the branching factor; m is the maximum
depth of the search tree; d is the depth of the shallowest solution, or is m when there
is no solution; l is the depth limit. Superscript caveats are as follows: 1 complete if b is
finite, and the state space either has a solution or is finite. 2 complete if all action costs
are ; 3 cost-optimal if action costs are all identical; 4 if both directions are
breadth-first or uniform-cost.

You might also like