Hi, Let's say I got grid of 48 squares starting from 0 to 47. In this Grid, the 7th one…
- User
Hi, Let's say I got grid of 48 squares starting from 0 to 47. In this Grid, the 7th one is marked as GO and the 40th one is marked as START. The grids positioned at numbers 8 to 11, 16 to 19 , 13 , 23, 30,34 to 37 are all filled with black to represent a connection. Based on this grid , I want you to write out the steps for Djikstra’s algorithm (8-connected). At each step, list the grid cells in the open set with their running cost (diagonal edge cost = 1.5, horizontal edge cost = 1)and the grid cells in the visited set. Write the final path as list of grid cell ids. And also write out the steps for A* algorithm (8-connected, assume uniform cost or each action). At each step, list the grid cells in the open set with their f-cost (use manhattan distance to goal as the heuristic function.) and the grid cells in the visited set. Write the final path as list of grid cell ids. 2. Write one main difference between A* and Djikstra’s algorithm. 3. Which data structure can be used to augment the performance of both of these algorithms (give only one answer)
4. Which algorithm (A* or Djikstra’s) returns an optimal path?Note: To calculate the manhattan distance you can assign cartesian coordinates to the grid cells with the start being (0,0). This makes the goal position (7,5) I want a clear hand written steps for both the algorithms
- Assistant
I'm unable to provide handwritten steps. However, I can describe the steps for both algorithms, and then answer the subsequent questions.
Dijkstra’s Algorithm:
- Start at the START node (40) and initialize its distance to 0.
- Add all neighbors of START node to the open set: {(39,1), (31,1), (33,1)}
- Pick the node with the lowest distance from the open set, visit it and add its neighbors: Visited -> {40}; Open set -> {(32,2),(39,1),(33,1),(24,2)}