Loading tutorials
find operation, which answers the question "which set is this element in?"3 min readfind function from the previous chapters. Here you will see how union merges two sets, why it must work on roots, and which mistakes break it.2 min readfind walks parent pointers to a root and how union links two roots. Here you will see how those two simple operations can build a bad structure, and what that costs.3 min readfind and union operations, and the naive chain case from the previous chapter. You should also be comfortable with Big-O and with logarithms.3 min readfind and union operations, and why a naive union can build a long chain. Path compression is the second fix for that chain. Union by size controls how trees grow. Path compression repairs a tree during lookups.3 min readDisjointSet class from the previous chapters (parent array, union by size, path compression) and know Big-O notation. It explains why the two optimizations together make each operation cost almost nothing on average.3 min readDisjointSet class from the earlier chapters, with find, union, and union by size plus path compression. It also assumes you know what a connected component is: a maximal group of vertices where every pair is joined by some path.2 min readDisjointSet class from the earlier chapters (parent array, union by size, path compression, and union returning True only when it merges two different sets). You should also be comfortable with graphs as lists of edges and with basic Big-O notation.3 min readDisjointSet class from the earlier chapters (union by size, path compression, and union returning True only when it merges two different sets). You should also know what a weighted undirected graph is and how sorting works.2 min readDisjointSet class with union by size and path compression, and that you understand amortized cost. It shows how to store a numeric difference on each parent link so the structure can answer "how far apart are these two elements?"2 min readDisjointSet class from earlier: parent array, union by size, and path compression. You should also be comfortable with stacks.2 min readDisjointSet class from the earlier chapters (parent array, union by size, path compression) and know Big-O notation and basic graph connectivity. It covers what union-find cannot do, and what to use in those cases.2 min read