Computer scienceAlgorithms and Data StructuresAlgorithmsGraph algorithmsShortest path algorithms

Lee's algorithm

Calculating Distances

Report a typo

Apply the Lee algorithm to find the shortest distances from a start point SS to all other points of the following grid:

Calculating Distances

Output your answer as a 2D matrix, where the "o" symbol denotes an obstacle, "s" is a start point, a number is the shortest distance. For example, your output may look like this:

s 1 2 3 4
1 2 3 4 5
2 3 4 5 6
o o o o o
Enter a short text
___

Create a free account to access the full topic