Loading topic
collections.deque. We use V for the number of vertices and E for the number of edges throughout.7 min readseen array, an explicit stack, and collections.deque. The goal here is to apply the same component-finding idea to a grid, where the graph is nev6 min readfind(x) follows parent pointers up to a root, and union(a, b) links one root under another. That version is correct, but some sequences of unions make it slow. This chapter covers the two standard fixes, shows why each one works, and exp6 min readfind and union do, and why path compression and union by size make each operation run in near-constant amortized time. It also assumes you can read Python classes and you know the BFS labeling approach from 5 min read