Lect Topic3 Search Sem1 0910
Lect Topic3 Search Sem1 0910
Note: Some parts of the lecture slides are referred to notes of Prof. Michael Pazzani, University of Irvine, California.
The Relation of Problem Solving
And Search
Problem Solving as Search (1)
Example
parent nodes
root node
A
B
C
D E
Breadth-First Search
the search process starts by examining all nodes
one level (also known as ply) down from the root node.
if the goal state is reached, success is reported.
Else, search continues by expanding paths from all
nodes in the current level down to the next level.
search continues until a goal node is met and
success is reported. Failure is reported when all nodes
have been examined but no goal node has been found.
A
1 2
B
C
3 4
D
E 6
5
F7 I J
8 9
G L
10 11 K
H
Techniques of Searching (4) A
B
C
Comparison between Depth-First and
D E
Breadth-First Search G
F
H I
The method may not be efficient – it may take longer time for
an optimal search to identify the optimal solution – but once it
has found, it is guaranteed to be the best one.
Breadth-first search is an optimal method.
Properties of Search Approaches
1 A
12
2 B
11 C
3 13 14
D 10 E
9
F 8 I J
4 15
7
6
G H
L
K
5
Some Calculations …
Calculating the number of nodes that need to be examined:
For a tree of depth d and with a branching factor of b, the total
number of nodes is:
1 root node A
b nodes in the first layer
2 B
b nodes in the second layer C
… D E
n th
b nodes in the n layer
G
Therefore, the total number of nodes is F
H I
2 3 d
1 + b + b + b+ … + b d+1
which is a geometric progression equal to 1 - b
1-b
Example
A tree with depth of 2 with a branching factor of 2, has
1 – 8 = 7 nodes
1–2
Using depth-first or breadth-first search, the total number
of nodes to be examined is 7.
Some Calculations …
Calculating the number of nodes that need to be examined:
Using DFID, nodes need to be examined more than once, resulting
to the following progression: number of nodes is:
2 3 d
(d + 1) + b (d) + b (d – 1) + b (d – 2)+… + b
d
Hence, DFID has a time complexity of O(b ). It has the memory
efficiency nof depth-first search because it only ever needs to store
information about the current path.
Hence, its space complexity is O(bd).
Example
Best-first search follows the best path available from the current
(partially developed) tree, rather than always follow a depth-first
approach.
Identifying Optimal Paths
Optimal path – path that involves the lowest cost or travels the
shortest distance from the start to goal node.
0, 0, 0 3, 3, 1 Goal
state