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

Implementing Randomized Kruskal’s Algorithm

To implement this, we’re going to create a new class to represent the state of the algorithm—the collection of information that it will use internally. Once we’ve got this State class written, the rest of Kruskal’s algorithm becomes almost trivial to implement. Don’t take my word for it, though. Watch and see!

As you saw in the previous section, Kruskal’s initially requires that each cell be associated with a unique set. This suggests that, at a minimum, our State class is going to need to track that association. We’ll need a way to query the set that a particular cell belongs to, as well as the list of cells that belong to a given set. Also, the algorithm wants to select random pairs of neighboring ...

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