uninformed Search Lecture 06 DEPTH FIRST AND BREADTH
uninformed Search Lecture 06
DEPTH FIRST AND BREADTH FIRST SEARCH l l l 1. 2. The data driven or goal driven search determines the direction of search The second issue is the order of search There are two possible orders Depth First Breadth First
DEPTH FIRST SEARCH Depth first is a simplification of back track algorithm l The descendent states are added and removed from the left end of OPEN. l OPEN is a LIFO structure. The organization of open as a stack directs search towards the most recently generated states l
DEPTH FIRST ALGORITHMS 1. 2. 3. 4. 5. 6. 7. 8. 9. Open =[Start], Closed =[] While Open != [] Remove left most state from Open call it X If X is a goal then return SUCCESS Generate children of X Put X on Closed Discard children of X if already on Open or Closed Put remaining children on left of Open Return FAIL
DEPTH FIRST SEARCH A B E K S F L T D C G M H N J I P O U Q R
DEPTH FIRST SEARCH # Open Closed 1 [A] [] 2 [BCD] [A] 3 [EFCD] [B, A] 4 [KLFCD] [EBA] =>
BREADTH FIRST ALGORITHMS Breadth first search explores the space in a level by level fashion. l Only when there are no more states to be explored at a given level does the algorithm move on the next level. l “Open” and “Closed” two lists are used to keep track of the search. Open is Like NSL having list of nodes whose children have not been examined. Closed records states that have already been examined. Closed is the union of DE and SL. l
BREADTH FIRST SEARCH A B E K S F L T D C G M H N J I P O U Q R
BREADTH FIRST SEARCH # Open Closed 1 [A] [] 2 [(A, B), (A, C), (A, D)] [A] 3 [C, D, (B, E), (B, F)] [(B, A), A] 4 [D, E, F, (C, G), (C, H)] [(C, A), (B, A), (A, NIL)] =>
DEPTH FIRST AND BREADTH FIRST SEARCH • • • BREADTH FIRST Examines the nodes in level by level fashion it always find the shortest path. If branching factor is high the algorithm may not be able to find a solution using the given memory space. Memory utilization is measured in terms of the number of open states on OPEN it is an exponential function of
DEPTH FIRST AND BREADTH FIRST SEARCH § § DEPTH FIRST Gets quickly into a deep search space. If it is known that the solution will be long, depth first search will not waste time. It can get lost deep in the graph Missing shorter paths Even becoming stuck in an infinitely long path that does not lead to a goal.
- Slides: 11