A Self-Study Routine to Mastering Algorithms

Image for post
Image for post

Algorithms are the key to any technical job, including programming and data science. Most companies test for ability to craft good algorithms more than anything else while recruiting. This is for a reason — computing languages are very easy to learn, ability to write algorithms is not.

I have learnt the hard way that algorithms is an acquired skill, like riding a bicycle, that you can learn only by practice. While nothing can beat a good teacher, try these steps to master your prowess at algorithms.

  1. Pick any computational problem that you fancy. Any simple ones from grade 10 math book will do. Lets say generating prime numbers less than N.
  2. Solve it the best you can. You don’t really need to know much about algorithms at this stage. Think about the simple math behind things and solve the problem.
  3. Then think about if this is the most efficient algo. Can this be done in a better way? How would you measure that?
  4. Now the fun starts. Look at the complexity of your solution. If lets say N = 100, how many steps will your program have to make. Lets call that t. Now how does that change when N = 1,000? Can that be reduced? Can you get to an algo where t is linearly dependent on N? Better than that?
  5. Next, think about how much storage your program is taking. Do you have to store long list of numbers? Can that be avoided? What is the trade-off between complexity and storage. Now you are talking real algos like professionals.
  6. Finally, how robust is your algo. If something breaks, how easy is it to recover. Surprisingly, many many software engineers doing this day in day out miss this point.
  7. Now think about how much time did it take you to go through these six steps. What is the intuition that would have let you come up with the best answers in the first attempt? Time to try the next problem, right from step 1.

Sure there are books and stuff that give you some good ideas. So would stack overflow. Just pick the problem and get started!

Written by

AI, Product, Strategy, Digital Transformation

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store