What is an algorithm? Why is it so vital for you as a developer or someone looking to come into tech?
Before my first lecture in college, I had already bought my textbooks and studied, and to be honest, nothing made sense to me.
After the usual introduction by the lecturer, he asked if anyone knew what algorithms were. We had brilliant people that already crammed the word and just spat it out. He laughed and made a statement I can never forget. He said, "One thing you all should bear in mind is that Algorithms are different for different people and different cases, all that matters is you solve the problem correctly and efficiently".
You may not have a background in tech. You may have studied computer science, but then the term- Algorithm didn't make so much sense to you, and that's why you're here to learn the word most simply.
I know you have questions; let's get right to it
Define an Algorithm
Informally, an algorithm is any well-defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values, as output.
By: MIT Introduction to Algorithm
However, algorithms are not just limited to computers. Every day, as humans and even robots, you make use of algorithms. Algorithms are well-defined steps required to complete a task.
You can think about it this way: if you've ever made a cup of coffee, tea, hot chocolate, followed the directions by Google Maps, or even a new pancake recipe, then you've used an algorithm.
An algorithm is just a fancy and nerdy name for a recipe or step-by-step guide to accomplish a task.
Let's try an example: How will you make a cup of coffee?
I'll go first :
Step 1: Get a mug from the rack. Step 2: Wash the cup. Step 3: Get a kettle. Step 4: Put water into the kettle. Step 5: Plug in the kettle and bring the water to a boil. Step 6: Switch off the socket and unplug the kettle. Step 7: Put two spoonfuls of coffee into a mug. Step 8: Pour in water to fill ⅔ of the cup. Step 9: Serve your coffee.
Note that you have to also keep in mind if the person has a coffee maker, if the person needs to use coffee beans or if they just had to pour some powder into a cup and make a cup. In this case, your algorithm may have loops because anybody using it may need to repeat some steps or go back to check some steps before continuing.
However, just like mentioned earlier, many things have to be considered before you write an algorithm. Algorithms are more effective when they are chosen specifically for a specific problem.
Ok, that is enough big words; let's break it down.
Algorithms Like I'm 5
When writing algorithms, it is essential to know that you may need additional tools, systems, and other approaches to achieve your goal for different problems. For instance, you will need flour to bake a cake, but what if you used cake flour and didn't specify what kind of flour is to be used in your recipe and a newbie picked up this recipe and used bean flour?
Which is fine, but did it solve the person's problem- bake a tasty birthday cake? No! Yeah, they may end up with something edible, but it's not the cake they wanted.
An algorithm is like a sketched plan. An outlined plan gives you an idea of what your dream apartment should be. It makes the task of drawing the actual plan easier.
Algorithms In Tech
Imagine a world where computers were infinitely fast, and you could use up as much space, and it wouldn't matter. Now, if we had such luxury of time, speed, and space, maybe algorithms wouldn't matter so much. You could pick the most convenient algorithm that you can implement and run with it.
Because after all, it didn't matter which algorithm you used, and memory wasn't an issue.
But we live in a world where computers are fast but not infinitely fast, memory can be inexpensive, but it is not exactly free. Therefore, computing time and space in memory are resources you should use wisely, and Algorithms that are efficient in terms of space and speed time will help you achieve this.
Why are algorithms so important?
Yeah, almost every company wants you to pass some fancy algorithm and Data Structure tests on Turing, hacker noon, or Leetcode before they hire you. Speaking to some recruiters helped me understand why it is essential to them. Understanding Algorithms and Data structures help the developer form an excellent background of good software engineering practices and insight into approaching technical problems.
Let's look at an example: Consider a Digital product like Bolt that determines how to travel from one location to another. Yes, the map shows available routes and sometimes highlights some challenges. However, an algorithm is required for certain operations such as 'finding the shortest route' to your destination (probably using a shortest-path algorithm) and rendering maps based on factors like traffic, e.t.c.
Another example can be when you decide to drive from Lagos Island to the Mainland; you may want to find driving directions from a website or even use a GPS or Google maps to find your shortest route and avoid the Lagos traffic.
The measure for the efficiency of an algorithm is speed, i.e. how long an algorithm takes to produce its result. It is also essential to know that there are some problems for which no efficient solution is known, and in this case, you may want to give it a shot and be the next big name in tech when you find an efficient way.
A list of my favourite resources to learn Algorithms:
There are a couple of resources on the internet to help you get started with Algorithms. However, I am recommending the following resources that I have used.
Algorithm for Dummies by John Paul Mueller and Luca Massaron
[CS50 Course on Algorithm] (youtube.com/watch?v=IFPedSR9wNU), and
Richards substack and weekly newsletter. Richard is a seasoned Software Engineering Lead at SEND Freight. In this weekly newsletter, Richard takes time to explain algorithms and Data structures to his readers like they're five. Yes! it's likeamfive.tech but for algorithms.
In summary, An algorithm can be defined as a step-by-step process of completing a task.
Developers make use of algorithms and Data structures every day of their working lives. And if, like me, you've been curious enough to open this article and try to understand the term, I hope this made it easier for you to understand.
Having a good understanding of algorithms, what they are, and the knowledge of when to apply them and how to apply them is essential to producing software that works accurately and performs efficiently.
Thank you for reading and I hope this made Algorithms easier to understand.
Follow us on Twitter @Like_am5 to request topics and connect with the community.