Algorithms¶
These are my notes on Algorithms. This is very much a work in progress. My plan is to put down everything in a rough way first, and keep refining it over time.
Philosophy¶
Broadly, I classify any algorithm or data structure into recursive or iterative. Of course, this is not a strict demarcation, but only in terms of the usual implementations or concpetualization.
As for data structures, there are two fundamental types in terms of how they are stored : contiguous storage (arrays, dynamic arrays) and linked storage (linked lists, trees, graphs)
Mental models¶
To effectively use a concept, it helps greatly to have the right mental model which allows you to use it in a consistent manner.
For example, understanding and thinking of binary search in terms of bisect left and bisect right makes it easy to actually use it in a consistent manner.
Another example, for array partitioning, just thinking of and defining the loop invariant correctly is key.
My effort is always to develop the correct understanding and mental model for any concept.
Call a thing by its right name¶
Just knowing the name of a thing is very powerful. Know the name of the problem and know the name of the algorithm.