You are on page 1of 2

Problem Set 1 Solutions

January 13, 2016


1. (2) What is the difference among BFS, DFS, and uniform-cost search
(Dijkstras algorithm) with respect to their implementations in the generic
tree search algorithm?
From a high level view, the three algorithms only differ in the way the
frontier is maintained. In particular, BFS keeps its frontier as a queue
(FIFO), DFS uses a stack (LIFO), and Dijkstra utilizes a priority queue
where nodes are ordered by their current path costs.
2. (2) A coworker of yours has a graph search problem and is comparing the
performance of different algorithms. Your coworker notices that depth
first search will sometimes result in a shorter cost path than uniform cost
search. Your coworker is confused because they thought that uniform
cost search was optimal. Assuming there arent any programming bugs,
what is the most likely reason uniform cost search will sometimes return
a greater cost path than depth first search?
The most likely reason is that the graph has edges with negative weight.
3. (2) Your coworker runs the same experiment comparing A* and Dijkstras
Algorithm. Surprisingly, every time they run the two algorithms Dijkstras
Algorithm returns a path with smaller cost than A*. Your coworker is
again confused because they were taught that A* is optimal. Given this
information (and assuming there arent any programming bugs) what is
the most likely reason A* would return a greater cost path than Dijkstras
Algorithm?
The most likely reason is that the heuristic given to A* is not admissible.
4. (2) Consider the two statements (a) BFS is a special case of uniform cost
search, and (b) uniform cost search is a special case of A*. Under what
conditions are they true?
(a) Uniform cost reduces to BFS when all edge costs are equal (and nonnegative).
(b) A* reduces to uniform cost if the heuristic is constant for every node.
5. Sudoku is a popular game in which the player tries to fill in all blank cells
so that the resulting board contains 1 to 9 on each row, each column, and
each 3 3 block.
1

a) (2) Formulate it as a graph search problem. What are the state space,
goal state, successor function, and the path costs?
State Space: All possible 9 by 9 boards such that every cell is
either blank or has an integer in [1,9] such that no integer is
repeated in any row, column or in any of the 3 x 3 grids.
Goal State: Any board in the state space such that there are no
blank cells.
Successor Function: Place an integer into any blank cell such
that it doesnt violate the no-repeated integers rule outlined
int he description of the state space.
path costs: Every edge cost is 1.
b) (2) Assume we use uninformed search. Which method would you
prefer? Why?
DFS. Because all paths to a goal state are the same distance away,
there is no advantage to using a BFS. However, there is a huge advantage to using DFS in regards to memory savings.

You might also like