Join us

Algorithms

1_Dl0F36mQqB_LNtA_dKd3ug.jpeg

This is one of the multiple articles that will be covering algorithms in detail. Developers struggle with these and I want to simplify them as much as possible, from basic to complex.

Whether you want to land a high-paying job as a software developer or want to land those exclusive gold medals in the competitive coding world.

What Are Algorithms?

Simply explained an algorithm is a step by step process of solving a computational problem.

We should always treat our computers as our less than intelligent friends, if you skip a step then the interpreter or compiler will return an error.

This is the stage where you ask, “so what is a program?”

And I will answer back saying “It is also a step by step procedure for solving a problem.”

At this stage, you are very confused, ready to give up and do not want to see coding ever again.

Before you do let’s compare the differences between program and algorithm.

Let's go through the table above in more detail:

Algorithms in Design Phase

In software development, we have the design and implementation phase. In the design phase we break down our business problem into smaller parts.

Then write these small sections as algorithms as to see if they will make business sense, and iron out the inner workings.

Program In Design Phase

Once our business problem has been simplified and written as algorithms then it can be implemented and turned into a program.

Algorithms Are Syntax Independent

We do not need to comply to any programming language specifications, We can use a combination of mathematics notation and plain English.

Programs Are Syntax Dependent

On the other hand, since we write the programs in the implementation stage then we use a programing language.

Each programing language has its own syntax, think of “syntax” as grammar. The interpreter and compiler will not understand you as you are breaking the syntax/grammar rules.

Algorithms Are Hardware Independent

We can write algorithms anywhere even on a whiteboard, hence you have whiteboard challenges at technical interviews. We do not need any specific hardware for this.

Programs on the other hand are written on IDE’s and are dependent on hardware to be executable.

Programs Are Hardware Dependent

As we are already in the implementation phase, then we need to talk to the machines to automate our business problem.

9/10 times humans can do these business tasks, perfect example is a recommender system. We have been recommending items to our fellow humans for decades now.

With this said machines do it better than us, as they are serial learners. While we are sleeping they are learning, while we are having fun we are sleeping, while we eating they are learning.

Point proven, machines are far more effective. Machines are simply put electronic hardware, we communicate with these using syntax.

Algorithms Are Analyzed

In computer science, we have what we call space and time complexity. This is an analysis of an algorithm.

How fast will our algorithm take to solve a problem and how much memory will it take.

Programs Are Not Analyzed

In the implementation stage we will just need to test our program, we have already analyzed the program as an algorithm.

Properties Of An Algorithm

Most Algorithms Need To Take In An Output

A problem could be structured as;

Write an algorithm to reverse a string. In this case our input is that string we need to reverse.

We have the string; “ Thenjiwe” and we want to reverse it to “ewijneht”. Then the string “Thenjiwe” is our input.

Algorithms Need To Produce An Output

Referring to the problem above, our input is “Thenjiwe” . Our Algorithm is supposed to reverse this string and maybe lowercase everything. Then our output will be “ewijneht”.

Algorithms Need To Be Clear

We need to know from the beginning which problems are we solving. Are we reversing characters, checking for repeating characters, finding the shortest path to a location etc.

Algorithms Need To End At Some Point

They have a start and end point. Then will start at a specific instruction and end at a specific instruction. The duration of an algorithm must be finite.

Algorithms Need To Be Effective

Your Algorithm does not need to be fancy and have multiple statements that will not be used in the programing stage.

Additional Reading

  1. http://www.edu4java.com/en/concepts/what-is-a-program-an-algorithm.html
  2. https://www.investopedia.com/terms/a/algorithm.asp#:~:text=An%20algorithm%20is%20a%20set,preparing%20a%20dish%20or%20meal.


Only registered users can post comments. Please, login or signup.

Start blogging about your favorite technologies, reach more readers and earn rewards!

Join other developers and claim your FAUN account now!

Avatar

The Maths Geek đŸ€“

@thenjikubheka
Mathematician | Software Engineer | Amazonian| Open Source | Blogger | Ban Killer Robots
User Popularity
328

Influence

32k

Total Hits

22

Posts