Sitemap

Understanding Algorithms

4 min readJul 25, 2022

--

Press enter or click to view image in full size
Photo by Brooke Cagle on Unsplash

They are everywhere, from the social media apps we use every day to the search engines, as long as you are interacting with digital technology whether on your computer, emails on your phone, you will be finding algorithms driving the content that you are interacting with anytime you are doing something on your computer, they are even present in our daily lives, from making coffee in the morning to selection of the best route to work, algorithms are being used everywhere. So what really is an algorithm?

An algorithm is simply a precisely defined sequence of steps for solving a problem or accomplishing a task.

Pictorial representation of algorithm

Assume you wish to receive instructions using a navigation app. When a location is chosen, the software employs an algorithm to examine the possible routes. It then checks the traffic using a different algorithm, and another algorithm is used to compute the best potential route through the jam.

A more common example is writing an algorithm to make coffee:

Press enter or click to view image in full size
Photo by Fahmi Fakhrudin on Unsplash

· Step 1: Put water in a kettle and let it boil for 5 minutes

· Step 2: Pour the water into a cup

· Step 3: Add your coffee to the water

· Step 4 (optional): Add your milk

With this simple steps you have written an algorithm for making coffee

How to Write an Algorithm

There are so many methods of writing algorithms so it does not really have a standard procedure to follow but before you begin writing an algorithm make sure the problem domain has been identified and well defined and the algorithm must solve the problem. Below are some characteristics of good algorithms:

1. Clear and unambiguous: The algorithm should be distinct in every way and lead to a single conclusion.

2. Well defined inputs and well defined outputs: An algorithm must indicate what output will be produced with the inputs well defined.

3. Finiteness: the algorithm must not result in infinite loops.

4. Feasible: It must be simple, generic and practical and it must be able to be executed with the resources available.

Get Eromosele Akhigbe’s stories in your inbox

Join Medium for free to get updates from this writer.

5. Language independent: It should be designed in such a manner that it is completely independent of the language. It must be simple instructions that can be implemented using any programming language

Analysis of Algorithms

Algorithms can be studied on two basis;

1. Priori Analysis: This refers to the theoretical analysis of an algorithm performed before its implementation. Before implementing the algorithm, other parameters such as processor speed, might be considered, which does not affect the implementation component.

2. Posteriori Analysis: This is an empirical analysis of an algorithm, it is utilizing any computer language to build the algorithm. The purpose of the analysis is to determine how much time and space the algorithm takes to operate.

Complexity of Algorithms

Algorithm complexity is a measure of how long an algorithm would take to complete given an input of size n.

Two factors that affect algorithms performance include:

1. Time complexity: This refers to the amount of time required to finish an algorithm execution. The time complexity is mainly determined by counting the number of steps required to complete a task

2. Space complexity: This is the quantity of space required to solve a problem and produce an output. It stores the program instruction, constant value, variable values and keeps track of function calls

Both space complexity and time complexity can be calculated using the big o notation. To find out more on that click here.

Some advantages of algorithms:

· They are easy to understand

· It is a step by step solution to a problem

· Divides complex problems into smaller steps

The only setback in writing algorithms is that for complex tasks it can be really time consuming.

Press enter or click to view image in full size
Photo by Austin Distel on Unsplash

As long as coding and programming are utilized, algorithms will remain at the center of these technologies, dictating what they do and how they do it. Thus, the art of designing algorithms should be normal practice for everyone because it enhances problem-solving abilities.

Thanks for listening !!

If you have any further questions you can put them down in the comment section and drop a few claps to encourage the writer.

--

--

Eromosele Akhigbe
Eromosele Akhigbe

Written by Eromosele Akhigbe

Building the Future🛰️ with Africa🌍