Code examples from Princeton's "Algorithms" textbook, 4th Edition.