SlideShare a Scribd company logo
1 of 66
Artificial Intelligence
Topic: Search Algorithms
by: Shweta Saraswat
Uninformed Search Algorithms:
The search algorithms in this section have no
additional information on the goal node other than the
one provided in the problem definition. The plans to
reach the goal state from the start state differ only by
the order and/or length of actions. Uninformed search
is also called Blind search.
The following uninformed search algorithms are:
Breadth First Search
Depth First Search
Iterative deepening
Bidirectional search
Uniform Cost Search
Breadth First Search:
Breadth-first search (BFS) is an algorithm for
traversing or searching tree or graph data structures.
It starts at the tree root (or some arbitrary node of a
graph, sometimes referred to as a ‘search key’), and
explores all of the neighbor nodes at the present depth
prior to moving on to the nodes at the next depth
level.
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.
example
example
example
The above image depicts the end-to-end process of Breadth-First
Search Algorithm. Let me explain this in more depth.
Assign ‘a’ as the root node and insert it into the Queue.
Extract node ‘a’ from the queue and insert the child nodes of ‘a’, i.e.,
‘b’ and ‘c’.
Print node ‘a’.
The queue is not empty and has node ‘b’ and ‘c’. Since ‘b’ is the first
node in the queue, let’s extract it and insert the child nodes of ‘b’, i.e.,
node ‘d’ and ‘e’.
Repeat these steps until the queue gets empty. Note that the nodes that
are already visited should not be added to the queue again.
BFS Algorithm
Set a variable NODE to the initial state, i.e., the root node.
Set a variable GOAL which contains the value of the goal
state.
Loop each node by traversing level by level until the goal
state is not found.
While performing the looping, start removing the elements
from the queue in FIFO order.
If the goal state is found, return goal state otherwise
continue the search.
Why do we need BFS Algorithm?
There are numerous reasons to utilize the BFS Algorithm to use as searching
for your dataset. Some of the most vital aspects that make this algorithm your
first choice are:
BFS is useful for analyzing the nodes in a graph and constructing the shortest
path of traversing through these.
BFS can traverse through a graph in the smallest number of iterations.
The architecture of the BFS algorithm is simple and robust.
The result of the BFS algorithm holds a high level of accuracy in comparison
to other algorithms.
BFS iterations are seamless, and there is no possibility of this algorithm
getting caught up in an infinite loop problem.
Applications of BFS Algorithm
Let’s take a look at some of the real-life applications where a BFS algorithm
implementation can be highly effective.
Un-weighted Graphs: BFS algorithm can easily create the shortest path and a
minimum spanning tree to visit all the vertices of the graph in the shortest time
possible with high accuracy.
P2P Networks: BFS can be implemented to locate all the nearest or neighboring
nodes in a peer to peer network. This will find the required data faster.
Web Crawlers: Search engines or web crawlers can easily build multiple levels of
indexes by employing BFS. BFS implementation starts from the source, which is the
web page, and then it visits all the links from that source.
Navigation Systems: BFS can help find all the neighboring locations from the main or
source location.
Network Broadcasting: A broadcasted packet is guided by the BFS algorithm to find
and reach all the nodes it has the address for.
Performance measures of BFS
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
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.
EXAMPLE
The path of traversal is:
A —-> B —-> D —-> E —-> C —-> F
DFS Algorithm
Set a variable NODE to the initial state, i.e., the root node.
Set a variable GOAL which contains the value of the goal
state.
Loop each node by traversing deeply in one direction/path
in search of the goal node.
While performing the looping, start removing the elements
from the stack in LIFO order.
If the goal state is found, return goal state otherwise
backtrack to expand nodes in other direction.
DFS
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.
Performance measures OF DFS
Application of DFS Algorithm
Application of DFS Algorithm
For finding the path
To test if the graph is bipartite
For finding the strongly connected components of a
graph
For detecting cycles in a graph
Difference between BFS and DFS
s.no. BFS DFS
1. BFS stands for Breadth First Search. DFS stands for Depth First Search.
2.
BFS(Breadth First Search) uses Queue data
structure for finding the shortest path.
DFS(Depth First Search) uses Stack data structure.
3.
BFS can be used to find single source shortest path
in an unweighted graph, because in BFS, we reach a
vertex with minimum number of edges from a
source vertex.
In DFS, we might traverse through more edges to
reach a destination vertex from a source.
4.
BFS is more suitable for searching vertices which
are closer to the given source.
DFS is more suitable when there are solutions away
from source.
5.
BFS considers all neighbors first and therefore not
suitable for decision making trees used in games or
puzzles.
DFS is more suitable for game or puzzle problems.
We make a decision, then explore all paths through
this decision. And if this decision leads to win
situation, we stop.
6.
The Time complexity of BFS is O(V + E) when
Adjacency List is used and O(V^2) when Adjacency
Matrix is used, where V stands for vertices and E
The Time complexity of DFS is also O(V + E) when
Adjacency List is used and O(V^2) when Adjacency
Matrix is used, where V stands for vertices and E
Why do (BFS) and (DFS) fail in the case of an infinite
search space?
In DFS, you would recursively look at a node’s adjacent vertex. DFS
may not end in an infinite search space. Also, DFS may not find the
shortest path to the goal. DFS needs O(d) space, where d is depth of
search.
BFS consumes too much memory. BFS needs to store all the elements
in the same level. In the case of a tree, the last level has N / 2 leaf
nodes, the second last level has N / 4. So, BFS needs O(N) space.
Iterative deepening depth first search (IDDFS) is a hybrid of BFS and
DFS. In IDDFS, we perform DFS up to a certain “limited depth,” and
keep increasing this “limited depth” after every iteration.
Iterative deepening
What is iterative deepening in artificial intelligence?
In computer science, iterative deepening search or
more specifically iterative deepening depth-first
search (IDS or IDDFS) is a state space/graph search
strategy in which a depth-limited version of depth-
first search is run repeatedly with increasing depth
limits until the goal is found.
INRODUCTION
Iterative deepening depth-first search (IDDFS) is an algorithm
that is an important part of an Uninformed search strategy just
like BFS and DFS. We can define IDDFS as an algorithm of an
amalgam of BFS and DFS searching techniques. In IDDFS, We
have found certain limitations in BFS and DFS so we have done
hybridization of both the procedures for eliminating the
demerits lying in them individually. We do a limited depth-first
search up to a fixed “limited depth”. Then we keep on
incrementing the depth limit by iterating the procedure unless
we have found the goal node or have traversed the whole tree
whichever is earlier.
Working Algorithm of IDDFS
In the uninformed searching strategy, the BFS and DFS have
not been so ideal in searching the element in optimum time and
space. The algorithms only guarantee that the path will be
found in exponential time and space. So we found a method
where we can use the amalgamation of space competence of
DFS and optimum solution approach of BFS methods, and
there we develop a new method called iterative deepening using
the two of them. The main idea here lies in utilizing the re-
computation of entities of the boundary instead of stocking
them up. Every re-computation is made up of DFS and thus it
uses less space. Now let us also consider using BFS in iterative
deepening search.
Working Algorithm of IDDFS
Consider making a breadth-first search into an iterative deepening
search.
We can do this by having aside a DFS which will search up to a limit.
It first does searching to a pre-defined limit depth to depth and then
generates a route length1.
This is done by creating routes of length 1 in the DFS way. Next, it
makes way for routes of depth limit 2, 3 and onwards.
It even can delete all the preceding calculation all-time at the
beginning of the loop and iterate. Hence at some depth eventually the
solution will be found if there is any in the tree because the
enumeration takes place in order.
Iterative deepening
In order to implement the iterative deepening search
we have to mark differences among:
Breakdown as the depth limit bound was attained.
A breakdown where depth bound was not attained.
Iterative deepening
While in the case once we try the search method
multiple times by increasing the depth limit each time
and in the second case even if we keep on searching
multiple times since no solution exists then it means
simply the waste of time. Thus we come to the
conclusion that in the first case failure is found to be
failing unnaturally, and in the second case, the failure
is failing naturally.
Example of Iterative Deepening Depth-First Search
Example of Iterative Deepening Depth-First Search
Here in the given tree, the starting node is A and the depth
initialized to 0. The goal node is R where we have to find
the depth and the path to reach it. The depth from the
figure is 4. In this example, we consider the tree as a finite
tree, while we can consider the same procedure for the
infinite tree as well. We knew that in the algorithm of
IDDFS we first do DFS till a specified depth and then
increase the depth at each loop. This special step forms the
part of DLS or Depth Limited Search.
the following traversal shows the IDDFS search.
Advantages
IDDFS gives us the hope to find the solution if it exists in the tree.
When the solutions are found at the lower depths say n, then the algorithm proves to be efficient
and in time.
The great advantage of IDDFS is found in-game tree searching where the IDDFS search operation
tries to improve the depth definition, heuristics, and scores of searching nodes so as to enable
efficiency in the search algorithm.
Another major advantage of the IDDFS algorithm is its quick responsiveness. The early results
indications are a plus point in this algorithm. This followed up with multiple refinements after the
individual iteration is completed.
Though the work is done here is more yet the performance of IDDFS is better than single BFS and
DFS operating exclusively.
Space and time complexities are expressed as: O(d) and here d is defined as goal depth.
Let us consider the run time of IDDFS. Let say b>l where b is branching factor and l is the depth
limit. Then next we search the goal node under the bound k. On the depth k, we say there may
be bknodes that are only generated once. Similarly, the nodes at the depth limit k-1 is twice and
thrice for k-2 depth. Thus the node generated at depth l is k times.
Disadvantages
The time taken is exponential to reach the goal node.
The main problem with IDDFS is the time and wasted
calculations that take place at each depth.
The situation is not as bad as we may think of especially when
the branching factor is found to be high.
The IDDFS might fail when the BFS fails. When we are to find
multiple answers from the IDDFS, it gives back the success
nodes and its path once even if it needs to be found again after
multiple iterations. To stop the depth bound is not increased
further.
Performance measures
Completeness: This algorithm is complete is ifthe
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
In normal graph search using BFS/DFS we begin our
search in one direction usually from source vertex toward
the goal vertex, but what if we start search from both
direction simultaneously.
Bidirectional search is a graph search algorithm which find
smallest path from source to goal vertex. It runs two
simultaneous search –
Forward search from source/initial vertex toward goal
vertex
Backward search from goal/target vertex toward source
vertex
Bidirectional Search
Bidirectional search replaces single search
graph(which is likely to grow exponentially) with two
smaller sub graphs – one starting from initial vertex
and other starting from goal vertex. The search
terminates when two graphs intersect.
Consider following simple example-
EXAMPLE
Suppose we want to find if there exists a path from
vertex 0 to vertex 14. Here we can execute two
searches, one from vertex 0 and other from vertex 14.
When both forward and backward search meet at
vertex 7, we know that we have found a path from
node 0 to 14 and search can be terminated now. We
can clearly see that we have successfully avoided
unnecessary exploration.
Why bidirectional approach?
Because in many cases it is faster, it dramatically reduce the
amount of required exploration.
Suppose if branching factor of tree is b and distance of goal
vertex from source is d, then the normal BFS/DFS
searching complexity would be O(bd). On the other hand, if
we execute two search operation then the complexity would
be O(bd/2) for each search and total complexity would
be O(bd/2 +bd/2) which is far less than O(bd).
When to use bidirectional approach?
We can consider bidirectional approach when-
Both initial and goal states are unique and completely
defined.
The branching factor is exactly the same in both
directions.
Performance measures
Completeness : Bidirectional search is complete if BFS
is used in both searches.
Optimality : It is optimal if BFS is used for search and
paths have uniform cost.
Time and Space Complexity : Time and space
complexity is O(bd/2).
Advantages
Below are the advantages:
One of the main advantages of bidirectional
searches is the speed at which we get the desired
results.
It drastically reduces the time taken by the search by
having simultaneous searches.
It also saves resources for users as it requires less
memory capacity to store all the searches.
Disadvantages
Below are the disadvantages:
The fundamental issue with bidirectional search is that the user
should be aware of the goal state to use bidirectional search and
thereby to decrease its use cases drastically.
The implementation is another challenge as additional code and
instructions are needed to implement this algorithm, and also care has
to be taken as each node and step to implement such searches.
The algorithm must be robust enough to understand the intersection
when the search should come to an end or else there’s a possibility of
an infinite loop.
It is also not possible to search backwards through all states.
COMPARATIVE mEASURES
What is uniform-cost search?
Uniform-cost search is an uninformed search
algorithm that uses the lowest cumulative cost to find
a path from the source to the destination. Nodes are
expanded, starting from the root, according to the
minimum cumulative cost. The uniform-cost search is
then implemented using a Priority Queue.
Algorithm for uniform cost search:
Insert the root node into the priority queue
Repeat while the queue is not empty:
Remove the element with the highest priority
If the removed node is the destination, print total cost
and stop the algorithm
Else, enqueue all the children of the current node to
the priority queue, with their cumulative cost from the
root as priority
Advantages &disadvantages of UCS
Advantages:
Uniform cost search is optimal because at every state the
path with the least cost is chosen.
Disadvantages:
It does not care about the number of steps involve in
searching and only concerned about path cost. Due to
which this algorithm may be stuck in an infinite loop.
Hill Climbing Algorithm
A hill-climbing algorithm is an Artificial Intelligence
(AI) algorithm that increases in value continuously
until it achieves a peak solution. This algorithm is used
to optimize mathematical problems and in other real-
life applications like marketing and job scheduling.
A hill-climbing algorithm
A hill-climbing algorithm is a local search algorithm
that moves continuously upward (increasing) until the
best solution is attained. This algorithm comes to an
end when the peak is reached.
hill-climbing algorithm
This algorithm has a node that comprises two parts: state
and value.
It begins with a non-optimal state (the hill’s base) and
upgrades this state until a certain precondition is met.
The heuristic function is used as the basis for this
precondition.
The process of continuous improvement of the current state
of iteration can be termed as climbing. This explains why
the algorithm is termed as a hill-climbing algorithm.
objective
A hill-climbing algorithm’s objective is to attain an
optimal state that is an upgrade of the existing state.
When the current state is improved, the algorithm will
perform further incremental changes to the improved
state. This process will continue until a peak solution is
achieved. The peak state cannot undergo further
improvements.
Features of a hill climbing algorithm
It employs a greedy approach: This means that it moves in a direction in which
the cost function is optimized. The greedy approach enables the algorithm to
establish local maxima or minima.
No Backtracking: A hill-climbing algorithm only works on the current state
and succeeding states (future). It does not look at the previous states.
Feedback mechanism: The algorithm has a feedback mechanism that helps it
decide on the direction of movement (whether up or down the hill). The
feedback mechanism is enhanced through the generate-and-test technique.
Incremental change: The algorithm improves the current solution by
incremental changes.
Types of hill climbing algorithms
Simple hill climbing
Steepest – Ascent hill climbing
Stochastic hill climbing
Simple Hill Climbing:
Simple hill climbing is the simplest way to implement a hill
climbing algorithm. It only evaluates the neighbor node
state at a time and selects the first one which optimizes
current cost and set it as a current state. It only checks it's
one successor state, and if it finds better than the current
state, then move else be in the same state. This algorithm
has the following features:
Less time consuming
Less optimal solution and the solution is not guaranteed
Algorithm for Simple Hill Climbing:
Step 1: Evaluate the initial state, if it is goal state then return success
and Stop.
Step 2: Loop Until a solution is found or there is no new operator left
to apply.
Step 3: Select and apply an operator to the current state.
Step 4: Check new state:
If it is goal state, then return success and quit.
Else if it is better than the current state then assign new state as a
current state.
Else if not better than the current state, then return to step2.
Step 5: Exit.
2. Steepest-Ascent hill climbing:
The steepest-Ascent algorithm is a variation of simple hill climbing algorithm. This algorithm
examines all the neighboring nodes of the current state and selects one neighbor node which is
closest to the goal state. This algorithm consumes more time as it searches for multiple neighbors
Algorithm for Steepest-Ascent hill climbing:
Step 1: Evaluate the initial state, if it is goal state then return success and stop, else make current
state as initial state.
Step 2: Loop until a solution is found or the current state does not change.
Let SUCC be a state such that any successor of the current state will be better than it.
For each operator that applies to the current state:
Apply the new operator and generate a new state.
Evaluate the new state.
If it is goal state, then return it and quit, else compare it to the SUCC.
If it is better than SUCC, then set new state as SUCC.
If the SUCC is better than the current state, then set current state to SUCC.
Step 5: Exit.
3. Stochastic hill climbing:
Stochastic hill climbing does not examine for all its
neighbor before moving. Rather, this search algorithm
selects one neighbor node at random and decides
whether to choose it as a current state or examine
another state.
State-space Diagram for Hill Climbing:
The state-space landscape is a graphical representation of the
hill-climbing algorithm which is showing a graph between
various states of algorithm and Objective function/Cost.
On Y-axis we have taken the function which can be an objective
function or cost function, and state-space on the x-axis. If the
function on Y-axis is cost then, the goal of search is to find the
global minimum and local minimum. If the function of Y-axis is
Objective function, then the goal of the search is to find the
global maximum and local maximum.
State-space Diagram for Hill Climbing
Different regions in the state space landscape:
Local Maximum: Local maximum is a state which is better than its
neighbor states, but there is also another state which is higher than it.
Global Maximum: Global maximum is the best possible state of state
space landscape. It has the highest value of objective function.
Current state: It is a state in a landscape diagram where an agent is
currently present.
Flat local maximum: It is a flat space in the landscape where all the
neighbor states of current states have the same value.
Shoulder: It is a plateau region which has an uphill edge.
Problems in Hill Climbing Algorithm:
1. Local Maximum: A local maximum is a peak state in the
landscape which is better than each of its neighboring
states, but there is another state also present which is
higher than the local maximum.
Solution: Backtracking technique can be a solution of the
local maximum in state space landscape. Create a list of the
promising path so that the algorithm can backtrack the
search space and explore other paths as well.
Problems in Hill Climbing Algorithm
Problems in Hill Climbing Algorithm
2. Plateau: A plateau is the flat area of the search space in
which all the neighbor states of the current state contains
the same value, because of this algorithm does not find any
best direction to move. A hill-climbing search might be lost
in the plateau area.
Solution: The solution for the plateau is to take big steps or
very little steps while searching, to solve the problem.
Randomly select a state which is far away from the current
state so it is possible that the algorithm could find non-
plateau region.
Problems in Hill Climbing Algorithm
Problems in Hill Climbing Algorithm
3. Ridges: A ridge is a special form of the local
maximum. It has an area which is higher than its
surrounding areas, but itself has a slope, and cannot
be reached in a single move.
Solution: With the use of bidirectional search, or by
moving in different directions, we can improve this
problem.
Problems in Hill Climbing Algorithm
This is all about uninformed search algorithms.

More Related Content

Similar to Search Algorithms in AI.pptx

Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AIKirti Verma
 
Search strategies BFS, DFS
Search strategies BFS, DFSSearch strategies BFS, DFS
Search strategies BFS, DFSKuppusamy P
 
Comparative Study of RBFS & ARBFS Algorithm
Comparative Study of RBFS & ARBFS AlgorithmComparative Study of RBFS & ARBFS Algorithm
Comparative Study of RBFS & ARBFS AlgorithmIOSR Journals
 
What is A * Search? What is Heuristic Search? What is Tree search Algorithm?
What is A * Search? What is Heuristic Search? What is Tree search Algorithm?What is A * Search? What is Heuristic Search? What is Tree search Algorithm?
What is A * Search? What is Heuristic Search? What is Tree search Algorithm?Santosh Pandeya
 
ARTIFICIAL INTELLIGENCE UNIT 2(2)
ARTIFICIAL INTELLIGENCE UNIT 2(2)ARTIFICIAL INTELLIGENCE UNIT 2(2)
ARTIFICIAL INTELLIGENCE UNIT 2(2)SURBHI SAROHA
 
graphtraversals.pdf
graphtraversals.pdfgraphtraversals.pdf
graphtraversals.pdfSeethaDinesh
 
distributed depth-first search
distributed depth-first search distributed depth-first search
distributed depth-first search Nidhi Baranwal
 
uninformed search part 2.pptx
uninformed search part 2.pptxuninformed search part 2.pptx
uninformed search part 2.pptxMUZAMILALI48
 
Breadth first search (bfs)
Breadth first search (bfs)Breadth first search (bfs)
Breadth first search (bfs)Bishal Bhandari
 
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxRaviKiranVarma4
 
Breadth first search signed
Breadth first search signedBreadth first search signed
Breadth first search signedAfshanKhan51
 
AI3391 ARTIFICIAL INTELLIGENCE Session 8 Iterative deepening DFS and Bidirect...
AI3391 ARTIFICIAL INTELLIGENCE Session 8 Iterative deepening DFS and Bidirect...AI3391 ARTIFICIAL INTELLIGENCE Session 8 Iterative deepening DFS and Bidirect...
AI3391 ARTIFICIAL INTELLIGENCE Session 8 Iterative deepening DFS and Bidirect...Asst.prof M.Gokilavani
 

Similar to Search Algorithms in AI.pptx (20)

AI(Module1).pptx
AI(Module1).pptxAI(Module1).pptx
AI(Module1).pptx
 
Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AI
 
NEW-II.pptx
NEW-II.pptxNEW-II.pptx
NEW-II.pptx
 
Search strategies BFS, DFS
Search strategies BFS, DFSSearch strategies BFS, DFS
Search strategies BFS, DFS
 
Comparative Study of RBFS & ARBFS Algorithm
Comparative Study of RBFS & ARBFS AlgorithmComparative Study of RBFS & ARBFS Algorithm
Comparative Study of RBFS & ARBFS Algorithm
 
Ai unit-4
Ai unit-4Ai unit-4
Ai unit-4
 
What is A * Search? What is Heuristic Search? What is Tree search Algorithm?
What is A * Search? What is Heuristic Search? What is Tree search Algorithm?What is A * Search? What is Heuristic Search? What is Tree search Algorithm?
What is A * Search? What is Heuristic Search? What is Tree search Algorithm?
 
Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
 
ARTIFICIAL INTELLIGENCE UNIT 2(2)
ARTIFICIAL INTELLIGENCE UNIT 2(2)ARTIFICIAL INTELLIGENCE UNIT 2(2)
ARTIFICIAL INTELLIGENCE UNIT 2(2)
 
graphtraversals.pdf
graphtraversals.pdfgraphtraversals.pdf
graphtraversals.pdf
 
distributed depth-first search
distributed depth-first search distributed depth-first search
distributed depth-first search
 
uninformed search part 2.pptx
uninformed search part 2.pptxuninformed search part 2.pptx
uninformed search part 2.pptx
 
Chap11 slides
Chap11 slidesChap11 slides
Chap11 slides
 
DFS BFS and UCS in R
DFS BFS and UCS in RDFS BFS and UCS in R
DFS BFS and UCS in R
 
Week 7.pdf
Week 7.pdfWeek 7.pdf
Week 7.pdf
 
Breadth first search (bfs)
Breadth first search (bfs)Breadth first search (bfs)
Breadth first search (bfs)
 
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
 
Breadth first search signed
Breadth first search signedBreadth first search signed
Breadth first search signed
 
AI3391 ARTIFICIAL INTELLIGENCE Session 8 Iterative deepening DFS and Bidirect...
AI3391 ARTIFICIAL INTELLIGENCE Session 8 Iterative deepening DFS and Bidirect...AI3391 ARTIFICIAL INTELLIGENCE Session 8 Iterative deepening DFS and Bidirect...
AI3391 ARTIFICIAL INTELLIGENCE Session 8 Iterative deepening DFS and Bidirect...
 
Graph Theory
Graph TheoryGraph Theory
Graph Theory
 

More from Dr.Shweta

research ethics , plagiarism checking and removal.pptx
research ethics , plagiarism checking and removal.pptxresearch ethics , plagiarism checking and removal.pptx
research ethics , plagiarism checking and removal.pptxDr.Shweta
 
effective modular design.pptx
effective modular design.pptxeffective modular design.pptx
effective modular design.pptxDr.Shweta
 
software design: design fundamentals.pptx
software design: design fundamentals.pptxsoftware design: design fundamentals.pptx
software design: design fundamentals.pptxDr.Shweta
 
Informed search algorithms.pptx
Informed search algorithms.pptxInformed search algorithms.pptx
Informed search algorithms.pptxDr.Shweta
 
constraint satisfaction problems.pptx
constraint satisfaction problems.pptxconstraint satisfaction problems.pptx
constraint satisfaction problems.pptxDr.Shweta
 
review paper publication.pptx
review paper publication.pptxreview paper publication.pptx
review paper publication.pptxDr.Shweta
 
SORTING techniques.pptx
SORTING techniques.pptxSORTING techniques.pptx
SORTING techniques.pptxDr.Shweta
 
Recommended System.pptx
 Recommended System.pptx Recommended System.pptx
Recommended System.pptxDr.Shweta
 
semi supervised Learning and Reinforcement learning (1).pptx
 semi supervised Learning and Reinforcement learning (1).pptx semi supervised Learning and Reinforcement learning (1).pptx
semi supervised Learning and Reinforcement learning (1).pptxDr.Shweta
 
introduction to Statistical Theory.pptx
 introduction to Statistical Theory.pptx introduction to Statistical Theory.pptx
introduction to Statistical Theory.pptxDr.Shweta
 
Unit 2 unsupervised learning.pptx
Unit 2 unsupervised learning.pptxUnit 2 unsupervised learning.pptx
Unit 2 unsupervised learning.pptxDr.Shweta
 
unit 1.2 supervised learning.pptx
unit 1.2 supervised learning.pptxunit 1.2 supervised learning.pptx
unit 1.2 supervised learning.pptxDr.Shweta
 
Introduction of machine learning.pptx
Introduction of machine learning.pptxIntroduction of machine learning.pptx
Introduction of machine learning.pptxDr.Shweta
 
searching techniques.pptx
searching techniques.pptxsearching techniques.pptx
searching techniques.pptxDr.Shweta
 
LINKED LIST.pptx
LINKED LIST.pptxLINKED LIST.pptx
LINKED LIST.pptxDr.Shweta
 
complexity.pptx
complexity.pptxcomplexity.pptx
complexity.pptxDr.Shweta
 
Introduction to Data Science.pptx
Introduction to Data Science.pptxIntroduction to Data Science.pptx
Introduction to Data Science.pptxDr.Shweta
 

More from Dr.Shweta (20)

research ethics , plagiarism checking and removal.pptx
research ethics , plagiarism checking and removal.pptxresearch ethics , plagiarism checking and removal.pptx
research ethics , plagiarism checking and removal.pptx
 
effective modular design.pptx
effective modular design.pptxeffective modular design.pptx
effective modular design.pptx
 
software design: design fundamentals.pptx
software design: design fundamentals.pptxsoftware design: design fundamentals.pptx
software design: design fundamentals.pptx
 
Informed search algorithms.pptx
Informed search algorithms.pptxInformed search algorithms.pptx
Informed search algorithms.pptx
 
constraint satisfaction problems.pptx
constraint satisfaction problems.pptxconstraint satisfaction problems.pptx
constraint satisfaction problems.pptx
 
review paper publication.pptx
review paper publication.pptxreview paper publication.pptx
review paper publication.pptx
 
SORTING techniques.pptx
SORTING techniques.pptxSORTING techniques.pptx
SORTING techniques.pptx
 
Recommended System.pptx
 Recommended System.pptx Recommended System.pptx
Recommended System.pptx
 
semi supervised Learning and Reinforcement learning (1).pptx
 semi supervised Learning and Reinforcement learning (1).pptx semi supervised Learning and Reinforcement learning (1).pptx
semi supervised Learning and Reinforcement learning (1).pptx
 
introduction to Statistical Theory.pptx
 introduction to Statistical Theory.pptx introduction to Statistical Theory.pptx
introduction to Statistical Theory.pptx
 
Unit 2 unsupervised learning.pptx
Unit 2 unsupervised learning.pptxUnit 2 unsupervised learning.pptx
Unit 2 unsupervised learning.pptx
 
unit 1.2 supervised learning.pptx
unit 1.2 supervised learning.pptxunit 1.2 supervised learning.pptx
unit 1.2 supervised learning.pptx
 
Introduction of machine learning.pptx
Introduction of machine learning.pptxIntroduction of machine learning.pptx
Introduction of machine learning.pptx
 
searching techniques.pptx
searching techniques.pptxsearching techniques.pptx
searching techniques.pptx
 
LINKED LIST.pptx
LINKED LIST.pptxLINKED LIST.pptx
LINKED LIST.pptx
 
complexity.pptx
complexity.pptxcomplexity.pptx
complexity.pptx
 
queue.pptx
queue.pptxqueue.pptx
queue.pptx
 
STACK.pptx
STACK.pptxSTACK.pptx
STACK.pptx
 
dsa.pptx
dsa.pptxdsa.pptx
dsa.pptx
 
Introduction to Data Science.pptx
Introduction to Data Science.pptxIntroduction to Data Science.pptx
Introduction to Data Science.pptx
 

Recently uploaded

Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixingviprabot1
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 

Recently uploaded (20)

Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixing
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 

Search Algorithms in AI.pptx

  • 1. Artificial Intelligence Topic: Search Algorithms by: Shweta Saraswat
  • 2. Uninformed Search Algorithms: The search algorithms in this section have no additional information on the goal node other than the one provided in the problem definition. The plans to reach the goal state from the start state differ only by the order and/or length of actions. Uninformed search is also called Blind search.
  • 3. The following uninformed search algorithms are: Breadth First Search Depth First Search Iterative deepening Bidirectional search Uniform Cost Search
  • 4. Breadth First Search: Breadth-first search (BFS) is an algorithm for traversing or searching tree or graph data structures. It starts at the tree root (or some arbitrary node of a graph, sometimes referred to as a ‘search key’), and explores all of the neighbor nodes at the present depth prior to moving on to the nodes at the next depth level.
  • 5. 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.
  • 8. example The above image depicts the end-to-end process of Breadth-First Search Algorithm. Let me explain this in more depth. Assign ‘a’ as the root node and insert it into the Queue. Extract node ‘a’ from the queue and insert the child nodes of ‘a’, i.e., ‘b’ and ‘c’. Print node ‘a’. The queue is not empty and has node ‘b’ and ‘c’. Since ‘b’ is the first node in the queue, let’s extract it and insert the child nodes of ‘b’, i.e., node ‘d’ and ‘e’. Repeat these steps until the queue gets empty. Note that the nodes that are already visited should not be added to the queue again.
  • 9. BFS Algorithm Set a variable NODE to the initial state, i.e., the root node. Set a variable GOAL which contains the value of the goal state. Loop each node by traversing level by level until the goal state is not found. While performing the looping, start removing the elements from the queue in FIFO order. If the goal state is found, return goal state otherwise continue the search.
  • 10. Why do we need BFS Algorithm? There are numerous reasons to utilize the BFS Algorithm to use as searching for your dataset. Some of the most vital aspects that make this algorithm your first choice are: BFS is useful for analyzing the nodes in a graph and constructing the shortest path of traversing through these. BFS can traverse through a graph in the smallest number of iterations. The architecture of the BFS algorithm is simple and robust. The result of the BFS algorithm holds a high level of accuracy in comparison to other algorithms. BFS iterations are seamless, and there is no possibility of this algorithm getting caught up in an infinite loop problem.
  • 11. Applications of BFS Algorithm Let’s take a look at some of the real-life applications where a BFS algorithm implementation can be highly effective. Un-weighted Graphs: BFS algorithm can easily create the shortest path and a minimum spanning tree to visit all the vertices of the graph in the shortest time possible with high accuracy. P2P Networks: BFS can be implemented to locate all the nearest or neighboring nodes in a peer to peer network. This will find the required data faster. Web Crawlers: Search engines or web crawlers can easily build multiple levels of indexes by employing BFS. BFS implementation starts from the source, which is the web page, and then it visits all the links from that source. Navigation Systems: BFS can help find all the neighboring locations from the main or source location. Network Broadcasting: A broadcasted packet is guided by the BFS algorithm to find and reach all the nodes it has the address for.
  • 13. 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.
  • 14. DFS will follow 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.
  • 15. EXAMPLE The path of traversal is: A —-> B —-> D —-> E —-> C —-> F
  • 16. DFS Algorithm Set a variable NODE to the initial state, i.e., the root node. Set a variable GOAL which contains the value of the goal state. Loop each node by traversing deeply in one direction/path in search of the goal node. While performing the looping, start removing the elements from the stack in LIFO order. If the goal state is found, return goal state otherwise backtrack to expand nodes in other direction.
  • 17. DFS 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.
  • 19. Application of DFS Algorithm Application of DFS Algorithm For finding the path To test if the graph is bipartite For finding the strongly connected components of a graph For detecting cycles in a graph
  • 20. Difference between BFS and DFS s.no. BFS DFS 1. BFS stands for Breadth First Search. DFS stands for Depth First Search. 2. BFS(Breadth First Search) uses Queue data structure for finding the shortest path. DFS(Depth First Search) uses Stack data structure. 3. BFS can be used to find single source shortest path in an unweighted graph, because in BFS, we reach a vertex with minimum number of edges from a source vertex. In DFS, we might traverse through more edges to reach a destination vertex from a source. 4. BFS is more suitable for searching vertices which are closer to the given source. DFS is more suitable when there are solutions away from source. 5. BFS considers all neighbors first and therefore not suitable for decision making trees used in games or puzzles. DFS is more suitable for game or puzzle problems. We make a decision, then explore all paths through this decision. And if this decision leads to win situation, we stop. 6. The Time complexity of BFS is O(V + E) when Adjacency List is used and O(V^2) when Adjacency Matrix is used, where V stands for vertices and E The Time complexity of DFS is also O(V + E) when Adjacency List is used and O(V^2) when Adjacency Matrix is used, where V stands for vertices and E
  • 21. Why do (BFS) and (DFS) fail in the case of an infinite search space? In DFS, you would recursively look at a node’s adjacent vertex. DFS may not end in an infinite search space. Also, DFS may not find the shortest path to the goal. DFS needs O(d) space, where d is depth of search. BFS consumes too much memory. BFS needs to store all the elements in the same level. In the case of a tree, the last level has N / 2 leaf nodes, the second last level has N / 4. So, BFS needs O(N) space. Iterative deepening depth first search (IDDFS) is a hybrid of BFS and DFS. In IDDFS, we perform DFS up to a certain “limited depth,” and keep increasing this “limited depth” after every iteration.
  • 22. Iterative deepening What is iterative deepening in artificial intelligence? In computer science, iterative deepening search or more specifically iterative deepening depth-first search (IDS or IDDFS) is a state space/graph search strategy in which a depth-limited version of depth- first search is run repeatedly with increasing depth limits until the goal is found.
  • 23. INRODUCTION Iterative deepening depth-first search (IDDFS) is an algorithm that is an important part of an Uninformed search strategy just like BFS and DFS. We can define IDDFS as an algorithm of an amalgam of BFS and DFS searching techniques. In IDDFS, We have found certain limitations in BFS and DFS so we have done hybridization of both the procedures for eliminating the demerits lying in them individually. We do a limited depth-first search up to a fixed “limited depth”. Then we keep on incrementing the depth limit by iterating the procedure unless we have found the goal node or have traversed the whole tree whichever is earlier.
  • 24. Working Algorithm of IDDFS In the uninformed searching strategy, the BFS and DFS have not been so ideal in searching the element in optimum time and space. The algorithms only guarantee that the path will be found in exponential time and space. So we found a method where we can use the amalgamation of space competence of DFS and optimum solution approach of BFS methods, and there we develop a new method called iterative deepening using the two of them. The main idea here lies in utilizing the re- computation of entities of the boundary instead of stocking them up. Every re-computation is made up of DFS and thus it uses less space. Now let us also consider using BFS in iterative deepening search.
  • 25. Working Algorithm of IDDFS Consider making a breadth-first search into an iterative deepening search. We can do this by having aside a DFS which will search up to a limit. It first does searching to a pre-defined limit depth to depth and then generates a route length1. This is done by creating routes of length 1 in the DFS way. Next, it makes way for routes of depth limit 2, 3 and onwards. It even can delete all the preceding calculation all-time at the beginning of the loop and iterate. Hence at some depth eventually the solution will be found if there is any in the tree because the enumeration takes place in order.
  • 26. Iterative deepening In order to implement the iterative deepening search we have to mark differences among: Breakdown as the depth limit bound was attained. A breakdown where depth bound was not attained.
  • 27. Iterative deepening While in the case once we try the search method multiple times by increasing the depth limit each time and in the second case even if we keep on searching multiple times since no solution exists then it means simply the waste of time. Thus we come to the conclusion that in the first case failure is found to be failing unnaturally, and in the second case, the failure is failing naturally.
  • 28. Example of Iterative Deepening Depth-First Search
  • 29. Example of Iterative Deepening Depth-First Search Here in the given tree, the starting node is A and the depth initialized to 0. The goal node is R where we have to find the depth and the path to reach it. The depth from the figure is 4. In this example, we consider the tree as a finite tree, while we can consider the same procedure for the infinite tree as well. We knew that in the algorithm of IDDFS we first do DFS till a specified depth and then increase the depth at each loop. This special step forms the part of DLS or Depth Limited Search.
  • 30. the following traversal shows the IDDFS search.
  • 31. Advantages IDDFS gives us the hope to find the solution if it exists in the tree. When the solutions are found at the lower depths say n, then the algorithm proves to be efficient and in time. The great advantage of IDDFS is found in-game tree searching where the IDDFS search operation tries to improve the depth definition, heuristics, and scores of searching nodes so as to enable efficiency in the search algorithm. Another major advantage of the IDDFS algorithm is its quick responsiveness. The early results indications are a plus point in this algorithm. This followed up with multiple refinements after the individual iteration is completed. Though the work is done here is more yet the performance of IDDFS is better than single BFS and DFS operating exclusively. Space and time complexities are expressed as: O(d) and here d is defined as goal depth. Let us consider the run time of IDDFS. Let say b>l where b is branching factor and l is the depth limit. Then next we search the goal node under the bound k. On the depth k, we say there may be bknodes that are only generated once. Similarly, the nodes at the depth limit k-1 is twice and thrice for k-2 depth. Thus the node generated at depth l is k times.
  • 32. Disadvantages The time taken is exponential to reach the goal node. The main problem with IDDFS is the time and wasted calculations that take place at each depth. The situation is not as bad as we may think of especially when the branching factor is found to be high. The IDDFS might fail when the BFS fails. When we are to find multiple answers from the IDDFS, it gives back the success nodes and its path once even if it needs to be found again after multiple iterations. To stop the depth bound is not increased further.
  • 33. Performance measures Completeness: This algorithm is complete is ifthe 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.
  • 34. Bidirectional Search In normal graph search using BFS/DFS we begin our search in one direction usually from source vertex toward the goal vertex, but what if we start search from both direction simultaneously. Bidirectional search is a graph search algorithm which find smallest path from source to goal vertex. It runs two simultaneous search – Forward search from source/initial vertex toward goal vertex Backward search from goal/target vertex toward source vertex
  • 35. Bidirectional Search Bidirectional search replaces single search graph(which is likely to grow exponentially) with two smaller sub graphs – one starting from initial vertex and other starting from goal vertex. The search terminates when two graphs intersect.
  • 37. EXAMPLE Suppose we want to find if there exists a path from vertex 0 to vertex 14. Here we can execute two searches, one from vertex 0 and other from vertex 14. When both forward and backward search meet at vertex 7, we know that we have found a path from node 0 to 14 and search can be terminated now. We can clearly see that we have successfully avoided unnecessary exploration.
  • 38. Why bidirectional approach? Because in many cases it is faster, it dramatically reduce the amount of required exploration. Suppose if branching factor of tree is b and distance of goal vertex from source is d, then the normal BFS/DFS searching complexity would be O(bd). On the other hand, if we execute two search operation then the complexity would be O(bd/2) for each search and total complexity would be O(bd/2 +bd/2) which is far less than O(bd).
  • 39. When to use bidirectional approach? We can consider bidirectional approach when- Both initial and goal states are unique and completely defined. The branching factor is exactly the same in both directions.
  • 40. Performance measures Completeness : Bidirectional search is complete if BFS is used in both searches. Optimality : It is optimal if BFS is used for search and paths have uniform cost. Time and Space Complexity : Time and space complexity is O(bd/2).
  • 41. Advantages Below are the advantages: One of the main advantages of bidirectional searches is the speed at which we get the desired results. It drastically reduces the time taken by the search by having simultaneous searches. It also saves resources for users as it requires less memory capacity to store all the searches.
  • 42. Disadvantages Below are the disadvantages: The fundamental issue with bidirectional search is that the user should be aware of the goal state to use bidirectional search and thereby to decrease its use cases drastically. The implementation is another challenge as additional code and instructions are needed to implement this algorithm, and also care has to be taken as each node and step to implement such searches. The algorithm must be robust enough to understand the intersection when the search should come to an end or else there’s a possibility of an infinite loop. It is also not possible to search backwards through all states.
  • 44. What is uniform-cost search? Uniform-cost search is an uninformed search algorithm that uses the lowest cumulative cost to find a path from the source to the destination. Nodes are expanded, starting from the root, according to the minimum cumulative cost. The uniform-cost search is then implemented using a Priority Queue.
  • 45. Algorithm for uniform cost search: Insert the root node into the priority queue Repeat while the queue is not empty: Remove the element with the highest priority If the removed node is the destination, print total cost and stop the algorithm Else, enqueue all the children of the current node to the priority queue, with their cumulative cost from the root as priority
  • 46. Advantages &disadvantages of UCS Advantages: Uniform cost search is optimal because at every state the path with the least cost is chosen. Disadvantages: It does not care about the number of steps involve in searching and only concerned about path cost. Due to which this algorithm may be stuck in an infinite loop.
  • 47. Hill Climbing Algorithm A hill-climbing algorithm is an Artificial Intelligence (AI) algorithm that increases in value continuously until it achieves a peak solution. This algorithm is used to optimize mathematical problems and in other real- life applications like marketing and job scheduling.
  • 48. A hill-climbing algorithm A hill-climbing algorithm is a local search algorithm that moves continuously upward (increasing) until the best solution is attained. This algorithm comes to an end when the peak is reached.
  • 49. hill-climbing algorithm This algorithm has a node that comprises two parts: state and value. It begins with a non-optimal state (the hill’s base) and upgrades this state until a certain precondition is met. The heuristic function is used as the basis for this precondition. The process of continuous improvement of the current state of iteration can be termed as climbing. This explains why the algorithm is termed as a hill-climbing algorithm.
  • 50. objective A hill-climbing algorithm’s objective is to attain an optimal state that is an upgrade of the existing state. When the current state is improved, the algorithm will perform further incremental changes to the improved state. This process will continue until a peak solution is achieved. The peak state cannot undergo further improvements.
  • 51. Features of a hill climbing algorithm It employs a greedy approach: This means that it moves in a direction in which the cost function is optimized. The greedy approach enables the algorithm to establish local maxima or minima. No Backtracking: A hill-climbing algorithm only works on the current state and succeeding states (future). It does not look at the previous states. Feedback mechanism: The algorithm has a feedback mechanism that helps it decide on the direction of movement (whether up or down the hill). The feedback mechanism is enhanced through the generate-and-test technique. Incremental change: The algorithm improves the current solution by incremental changes.
  • 52. Types of hill climbing algorithms Simple hill climbing Steepest – Ascent hill climbing Stochastic hill climbing
  • 53. Simple Hill Climbing: Simple hill climbing is the simplest way to implement a hill climbing algorithm. It only evaluates the neighbor node state at a time and selects the first one which optimizes current cost and set it as a current state. It only checks it's one successor state, and if it finds better than the current state, then move else be in the same state. This algorithm has the following features: Less time consuming Less optimal solution and the solution is not guaranteed
  • 54. Algorithm for Simple Hill Climbing: Step 1: Evaluate the initial state, if it is goal state then return success and Stop. Step 2: Loop Until a solution is found or there is no new operator left to apply. Step 3: Select and apply an operator to the current state. Step 4: Check new state: If it is goal state, then return success and quit. Else if it is better than the current state then assign new state as a current state. Else if not better than the current state, then return to step2. Step 5: Exit.
  • 55. 2. Steepest-Ascent hill climbing: The steepest-Ascent algorithm is a variation of simple hill climbing algorithm. This algorithm examines all the neighboring nodes of the current state and selects one neighbor node which is closest to the goal state. This algorithm consumes more time as it searches for multiple neighbors Algorithm for Steepest-Ascent hill climbing: Step 1: Evaluate the initial state, if it is goal state then return success and stop, else make current state as initial state. Step 2: Loop until a solution is found or the current state does not change. Let SUCC be a state such that any successor of the current state will be better than it. For each operator that applies to the current state: Apply the new operator and generate a new state. Evaluate the new state. If it is goal state, then return it and quit, else compare it to the SUCC. If it is better than SUCC, then set new state as SUCC. If the SUCC is better than the current state, then set current state to SUCC. Step 5: Exit.
  • 56. 3. Stochastic hill climbing: Stochastic hill climbing does not examine for all its neighbor before moving. Rather, this search algorithm selects one neighbor node at random and decides whether to choose it as a current state or examine another state.
  • 57. State-space Diagram for Hill Climbing: The state-space landscape is a graphical representation of the hill-climbing algorithm which is showing a graph between various states of algorithm and Objective function/Cost. On Y-axis we have taken the function which can be an objective function or cost function, and state-space on the x-axis. If the function on Y-axis is cost then, the goal of search is to find the global minimum and local minimum. If the function of Y-axis is Objective function, then the goal of the search is to find the global maximum and local maximum.
  • 58. State-space Diagram for Hill Climbing
  • 59. Different regions in the state space landscape: Local Maximum: Local maximum is a state which is better than its neighbor states, but there is also another state which is higher than it. Global Maximum: Global maximum is the best possible state of state space landscape. It has the highest value of objective function. Current state: It is a state in a landscape diagram where an agent is currently present. Flat local maximum: It is a flat space in the landscape where all the neighbor states of current states have the same value. Shoulder: It is a plateau region which has an uphill edge.
  • 60. Problems in Hill Climbing Algorithm: 1. Local Maximum: A local maximum is a peak state in the landscape which is better than each of its neighboring states, but there is another state also present which is higher than the local maximum. Solution: Backtracking technique can be a solution of the local maximum in state space landscape. Create a list of the promising path so that the algorithm can backtrack the search space and explore other paths as well.
  • 61. Problems in Hill Climbing Algorithm
  • 62. Problems in Hill Climbing Algorithm 2. Plateau: A plateau is the flat area of the search space in which all the neighbor states of the current state contains the same value, because of this algorithm does not find any best direction to move. A hill-climbing search might be lost in the plateau area. Solution: The solution for the plateau is to take big steps or very little steps while searching, to solve the problem. Randomly select a state which is far away from the current state so it is possible that the algorithm could find non- plateau region.
  • 63. Problems in Hill Climbing Algorithm
  • 64. Problems in Hill Climbing Algorithm 3. Ridges: A ridge is a special form of the local maximum. It has an area which is higher than its surrounding areas, but itself has a slope, and cannot be reached in a single move. Solution: With the use of bidirectional search, or by moving in different directions, we can improve this problem.
  • 65. Problems in Hill Climbing Algorithm
  • 66. This is all about uninformed search algorithms.