Prev Up Next
Go backward to Question 1
Go up to Top
Go forward to Question 3

Question 2

Consider the problem of finding a path in the grid shown below from the position s to the position g. A piece can move on the grid horizontally and vertically, one square at a time. No step may be made into a forbidden shaded area.
  1. On the grid, number the nodes in the order in which they are removed from the frontier in a depth-first search from s to g, given that the order of the operators you will test is: up, left, right, then down. Assume there is a cycle check.
  2. Number the nodes in order in which they are taken off the frontier for an A* search for the same graph. Manhattan distance should be used as the heuristic function. The Manhattan distance between two points is the distance in the x-direction plus the distance in the y-direction. It corresponds to the distance traveled along city streets arranged in a grid. For example, the Manhattan distance between g and s is 4. What is the path that is found?
  3. Assume that you were to solve the same problem using dynamic programming. Give the dist value for each node, and show which path is found.
  4. Based on this experience, discuss which algorithms are best suited for this problem.
  5. Suppose that the graph extended infinitely in all directions. That is, there is no boundary, but s, g, and the forbidden area are in the same relative positions to each other. Which methods would no longer find a path? Which would be the best method, and why?
  • Solution to Question 2, part 1
  • Solution to Question 2, part 2
  • Solution to Question 2, part 3
  • Solution to Question 2, part 4
  • Solution to Question 2, part 5

  • Prev Up Next