Question: Assume that the layout is a square grid and each cell contains an integer that represents the time to reach from one place to another.
Assume that the layout is a square grid and each cell contains an integer that represents the time to reach from one place to another. The residents need your help in finding the best possible route with the shortest time that can be used in case of emergency to reach the hospital. The source (House) and destination (Hospital) cells have a zero value. Which is the best route (shortest time) to reach the hospital from the residents house (design an algorithm and python code)? The house and hospital node should be taken as an input and is not fixed to the nodes mentioned in the grid above. Whats the total time taken?
|
| 1 | 2 | 3 | 4 |
| 1 | 0(source) | 5 | 11 | 13 |
| 2 | 16 | 1 | 6 | 17 |
| 3 | 4 | 8 | 11 | 7 |
| 4 | 1 | 1 3 | 3 | 0(dest) |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
