Often, algorithms are considered only when someone is looking for a new job. This tight perception of algorithms use puts us away from what algorithms can allow us to achieve!
Actually, algorithms are everywhere! Algorithms are involved in each aspect of computer science! Not only that but also used in a wide range of fields: recommendations, social media, medicine, psychology, transportation and the list is longer still!
Anything you do, can be broken down into small steps and that, is an Algorithm. Imagine you wake up the morning to go to work and you can’t remember where are your car keys, how would you find them? One approach might be to apply an algorithm, which is a step by step logical procedure. First, you look for places where you used to put it in. You try to remember the last time you used it. You check the place where you went when entering the home. Sooner or later by the flow of steps, you eventually find the car keys. An algorithm is a sequence of instructions which ensure a certain task completion. We, as human, apply algorithms in order to take actions in every aspect of our lives.
So, algorithm knowledge can be an asset in improving your life or even others’lives! You can turn something that takes the time to decide on it into an algorithm that assists you in the decision process. You can create an algorithm in order to prioritize your tasks, instead of doing it by a simple to-do list. You can make an algorithm in order to predict the best time to visit a city. You can make algorithm in order to get suggestions on what films to watch according to your preferences and historical data. There is no limit to what you imagine and can make real by applying algorithms!
Now, I think it’s time to start talking about how to gain those set of skills in order to make a difference with algorithms! First, let’s go for the characteristics of an algorithm.
What are the characteristics of an algorithm?
- It should be finite: If your algorithm never ends trying to solve the problem it was designed to solve then it is useless
- It should have well-defined instructions: Each step of the algorithm has to be precisely defined; the instructions should be unambiguously specified for each case.
- It should be effective: The algorithm should solve the problem it was designed to solve. And it should be possible to demonstrate that the algorithm converges with just a paper and pencil.
What are the steps to learn algorithm coding?
- Develop your programming logic. Here some ways to improve it.
- Pick up a programming language you are comfortable in (if you don’t have any, I suggest learning python, it’s easy and simple)
- Learn Data structures: Start with the basic ones: String, Vectors, Lists, Arrays, Map. Then Queue and Stack. Finish with Advanced ones: trees, graphs, tries.
- Practice coding data structures. Here is a good link
- Learn simple algorithms first and then move to the most common algorithms. Make sure you understand every step and don’t be frustrated from being slow. Remember « It does not matter how slowly you go as long as yo don’t stop ». You can look for videos because they make it easier to assimilate.
- Start tackling problems (e.g in Hackerrank, there are funny and challenging algorithms). You must have a strategy of resolving problems, I’d suggest following the method proposed by Gayle Laakmann McDowell.
Finally, through my own modest experience in problem-solving, here are my pieces of advice :
- Ask questions: « why » and « what » are really important in order to understand the basics of anything! When you question the choice, you will better memorize the answer and you will dig deeper into the source of the information.
- To stay motivated and keep the learning curve up, create a simple daily useful algorithm after getting the basics. Accomplishment fuels your energy.
- Try to solve the problem manually by yourself first. Take a paper and start writing steps. Especially take your time and don’t move on to the solution fast.
- Even if you figure out the solution, don’t tell yourself « It’s ok now, no need to implement it, I know how it works » It’s a big trick there because you never know what you missed if you don’t try it and test it with corner cases.
- Be patient. If you begin to feel frustrated about a problem, leave it and go do something that is not so stressful. Then, come back.
I hope this helps you to leverage the power of your brain, by discovering its super capabilities to execute algorithms and learning how to translate them into code! 😉
Remember how was Rome build (not in a day right)? By each small step in learning algorithms, you are growing your potential to contribute to making life better in this world!
- The Algorithm design Manual
- The pragmatic programmer
- Cracking the coding interview: programming questions, Java, C/c++.
Topcoder: an explanation of data structures and algorithms.
ideserve: contains a visual explanation of some algorithm problems
Tushar Roy : explanation of some advanced algorithms