You are on page 1of 30

SESSION 2

Artificial Intelligence

Dr. Sherin Youssef


Breadth-first search
 One of the search strategies that comes under the
heading of uninformed search.

 Breadth-first search is a simple strategy in which the


root node is expanded first, then all the successors of
the root node are expanded next, and so on.

 Expand shallowest unexpanded node.

 Implemented by a first-in-first-out queue.


Breadth-first search on a binary tree
Evaluating Breadth-first search
 The search is complete if the shallowest goal node is at some
finite depth d, and the branching factor b is finite.

 The shallowest goal node is not necessarily the optimal one;


technically, it is optimal if the path cost is a nondecreasing
function of the node depth .

 The root of the search tree generates b nodes at the first level,
each of which generates b more nodes, for a total of b² at the
second level. And so on.

 Keeps every node in memory, so space is the big problem.


Depth-first search
 One of the search strategies that comes under the
heading of uninformed search.

 Expand deepest unexpanded node.

 Implemented by a last-in-first-out queue.


Depth-first search on a binary tree
Evaluating Depth-first search
 Incomplete in infinite depths (get stuck going down a very
long path when a different choice would lead to a solution near
the root). Complete in finite depths.

 Not optimal. For example, if C and J are goal nodes in the


previous figures, then depth-first search will return J as a
solution, which is not optimal.

 Less memory is needed, the search needs to store only a single


path from the root to a leaf node, along with remaining
unexpanded nodes. A node can be removed from memory if
all its descendents have been explored.

 Less time is needed.


Greedy search
 One of the search strategies that comes under the
heading of informed search.

 Expand the node that appears to be closest to goal.


Example
Evaluating Greedy search
 Incomplete, can get stuck in loops. Complete in
finite space with repeated-state checking.

 Keeps all nodes in memory.

 Not optimal.
Local search
 Local search algorithms operate using a single current
state (rather than multiple path) and generally move
only to neighbors of that state.

 The paths followed by the search are not retained.

 Local search are useful for solving pure optimization


problems, in which the aim is to find the best state
according to an objective function.
Evaluating Local search
Although local search algorithms are not systematic,
they have two key advantages:

 Local search uses very little memory usually a constant


amount.

 Local search can often find reasonable solutions in large or


infinite state spaces for which systematic algorithms are
unsuitable.

 A complete local search algorithm always finds a goal, if one


exists; an optimal algorithm always finds a global
minimum/maximum.

You might also like