Loading topic
itertools, and that you know what an "optimal solution" means for an optimization problem. Proofs by contradiction come up briefly. The full proof techniques are covered in later chapters.7 min readheapq works as a min-heap, and are comfortable with proof by contradiction. It also builds on the earlier chapter on activity selection. That chapter picked the most intervals that fit in one room. This one fits every interva6 min readsorted and lambda, know that sorting costs O(n log n), and have read the earlier chapter on the exchange argument. The fractional knapsack is the clearest place to see that argument at work. It also sets up a contrast with dynamic programming that co6 min readheapq, that you know what a binary tree is, and that you have read the earlier chapters on the exchange argument and optimal substructure. The Huffman correctness proof uses both of those ideas.6 min readheapq), know adjacency lists and weighted undirected graphs, and have seen the exchange argument from the earlier chapter on proof techniques. You will use that argument again here to prove the cut property. Both Kruskal's algorithm and Prim's a7 min readheapq, adjacency lists, and the greedy-stays-ahead proof style from earlier in the tutorial. It covers single-source shortest paths: given a weighted directed graph and a source vertex s, find the length of the shortest path from s to 6 min read