This repo contains my solutions to Algorithms, Part I, the online Princeton course by Robert Sedgewick and Kevin Wayne. All 5 solutions score 100% in correctness, timing and memory. More importantly, I have taken extra care to ensure the code is clean and that it reads like well-written prose.
My coding style can be summarised as:
- Use small functions that do one thing only and have no hidden side effects
- Have one level of abstraction per function (with small violations)
- Each function should take at most 4 non-related arguments (more work to be done on this)
- Prefer long, descriptive, intention-revealing names over comments
- Avoid comments if names are self-explanatory (including javadocs)
- Declarations of functions used in each function should be found as fast as possible below that function
- Conceptually linked functions should stay together
When I clean the code according to these rules, I can read it from top to bottom like a poem. I have found that not only is this visually pleasing but it also helps me understand the algorithms much better.
All PRs, even the ones with tiniest improvements, are welcome.