Cost vs. Distance

Learn the difference between cost and distance in mazes.

Comparing cost with distance

Imagine traversing a maze, and we come to a branch in the passage. In the illustration below, both paths loop around and meet up again a short distance later, but the passage to the left is blocked by a pool of molten lava. The passage to the right has no lava but is much longer than the other. Which path will get us to the exit faster?

Get hands-on with 1200+ tech skills courses.