Skip to Main Content
Mazes for Programmers
book

Mazes for Programmers

by Jamis Buck
July 2015
Intermediate to advanced content levelIntermediate to advanced
286 pages
6h 31m
English
Pragmatic Bookshelf
Content preview from Mazes for Programmers

Introducing Prim’s Algorithm

Prim’s algorithm was first developed in 1930 by a Czech mathematician named Vojtěch Jarník, but it gets its name from Robert C. Prim, a computer scientist who rediscovered it independently in 1957. It works similarly to Dijkstra’s algorithm, starting at one point in the grid and then moving outward like water flowing, but in Prim’s case it does more than just measure distances and costs. The end result of Prim’s is one of those fancy minimum spanning trees—or, in our case, a maze.

As with Kruskal’s algorithm, Prim’s works by considering the weights on the connections between cells—passage costs—rather than on the individual cells themselves. We’ll look at how this comes together, but then we’ll take a step back ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Exercises for Programmers

Exercises for Programmers

Brian P. Hogan

Publisher Resources

ISBN: 9781680501315Errata Page