Saved searches

Use saved searches to filter your results more quickly

Cancel Create saved search Sign up Reseting focus

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Solutions to exercises and problems from "Introduction to Algorithms", Fourth Edition by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein

License

Notifications You must be signed in to change notification settings

wojtask/clrs4e-solutions

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Go to file

Folders and files

Last commit message Last commit date

Latest commit

History

View all files

Repository files navigation

Introduction to Algorithms, Fourth Edition — solutions to exercises and problems

Overview

However, none of the above sources cover all exercises, especially when compared to the fourth edition that adds a significant number of new exercises. Also, I noticed that some solutions are not of the highest quality, with defects ranging from incorrectness or incompleteness to the lack of technical elegance. Nevertheless, these pieces of work were sources of inspiration for me, and showed different approaches and perspectives. When borrowing on the ideas presented there, I always aimed to rework the solutions by introducing necessary fixes and improvements, and refine to improve consistency with the book.

The solutions here often refer to the material presented in the textbook, so familiarity on at least the corresponding chapter is required. In many solutions, you will also find references to other tasks, especially when a given task uses the result of another in its own solution. In general, later solutions sometimes rely on the earlier ones by referencing the relevant exercises. Thus, in early chapters one can observe a somewhat greater focus on details, and in later chapters more cross-references to exercises where those details have already been discussed.

I keep an eye on errors or inaccuracies in exercises and problems or the material they directly rely on, and highlight them in brief notes just before the solution of the affected exercise. At the same time I refer to the textbook's errata — if it includes a certain correction, I assume that the bug has already been fixed in a subsequent printing.

As I stressed earlier, I pay special attention to ensuring the correctness of the algorithms and data structures operations. To maximize my confidence, I implement and test each pseudocode or algorithm description that I provide in the solutions, as well as those that are provided in the textbook. I chose Python as a programming language, because of its popularity and its syntax similar to that used in pseudocodes. The counterpart project with implementations is available here.

History

The origins of the project date back to 2005, when I started solving exercises by pen and paper, while studying algorithms as a preparation for participating in the Polish Olympiad in Informatics. I was relying on the Polish translation of the textbook's second edition, titled Wprowadzenie do algorytmów, and my solutions were in Polish as well. In 2009 I started rewriting them in LaTeX. The document has evolved since then, with changes involving numerous fixes, improved page layout and styling, as well as open sourcing it on GitHub as CormenSol. At the beginning the pictures were drawn in MetaPost, before having been rewritten to PGF/TikZ in 2016. In 2012 I started implementing algorithms, first in C++, then in Java, before finally settling on Python in 2017, and I open sourced the implementations as CormenPy. Since initiating the project, the textbook got updated to the third edition in 2009, then to fourth edition in 2022. Having solved Chapters 1-17 and Appendices A-C from the — now outdated — second edition, I decided to freeze both CormenSol and CormenPy, and shift my attention to adapt the solutions for the fourth edition, while translating them to English — the process I refer to as migration.

The work on the current project began on January 1, 2023.

Progress

Part I Part II Part III Part IV Part V Part VI Part VII Part VIII































Roadmap