# Quiz 4-26-’07 Search.

## Presentation on theme: "Quiz 4-26-’07 Search."— Presentation transcript:

Quiz 4-26-’07 Search

Dijkstra’s Shortest Path Algorithm:
Consider the following algorithm to find the shortest distance between two cities (S  G) A. Maintain a list of cities C that you have visited so far. Cache the total path-cost g(c) and the predecessor city p(c) for every city c in C. B. Maintain a list of neighboring cities F (the fringe) that are not in C: Cache the total path-cost g(f) and the predecessor city p(f) for every city f in F. Cities in F are ordered according to their total path cost g(f) C. At every iteration of the algorithm, starting at S, visit the city in the fringe that has the lowest path-cost Add it to C and remove it from F. D. Add all new neighboring cities (including their g(f) and p(f)) into the fringe that are not already in C. (They could already be in F though with a different predecessor) E. If more than 1 copy of a city is in the fringe, only retain the one with lowest g(f). Delete all other copies. F. If you reach G, reconstruct the path from SG and report g(G) and the path. 1. [2pts] Work out the first 3 steps of Dijkstra’s algorithm and uniform cost search (UC with repeated states). This means: visit and expand the first 3 nodes starting at 0. Use the graph to the right. “0” is the source and “6” is the goal. 2. [2pts] Is this algorithm an instance of a informed or an uninformed search algorithm? (explain) 3. [2pts] Is this algorithm an instance of a tree search or a graph search 4. [2pts] Is this algorithm complete? (explain) 5. [2pts] Is this algorithm optimal? (explain – you may describe it as an instance of some algorithm in the book and refer to results described in the book)

Solution Notation for Dijkstra: node (total path cost, predecessor)
Notation for Uniform cost: node (total path cost) Dijkstra Nodes visited and expanded: 0 (0, null), 1 (1.1, 0), 3 (3.5, 1) Uniform cost Nodes visited and expanded: 0 (0), 1 (1.1), 0 (2.2) Uninformed (since does not use any estimate of the cost from node to a goal) Graph search (since the algorithm maintains a list of already expanded nodes) Yes, it is complete (guaranteed to find a solution) Yes, it is optimal (because it is uniform cost search with a detection of repeated states)