DEV Community

Cover image for Algorithms in a nutshell ; )
Rawan Amr Abdulsattar
Rawan Amr Abdulsattar

Posted on • Originally published at codewithrona.blogspot.com

Algorithms in a nutshell ; )

So what on Earth are the Algorithms...?

An Algorithm is a set of ordered instructions to reach an objective or output or complete a specific task or do a calculation.

We use Algorithms in problems, but wait a second , Do you really know what a problem is?

A Problem

A problem is the objective or the output we want to reach, or the task we want to complete . I think it is easy and straight forward , Right ;) ?

Making a cake is an example of a problem.

Problem Solving

and to solve a problem we do problem solving that can be done through 5 main steps which are:

1) Problem definition
2) Writing the algorithm
3) Implementation
4) Testing
5) Program documentation (a programming-specific step)

So by Applying this to our problem in the last example(Making a cake) then it will be like this :

Problem definition :

we want to make a cake and the :
1) output should be : a delicious cake
2) Input is : flour, milk, eggs, sugar and so on.

Writing the Algorithm

Steps are :
1) Mix all dry ingredients together lightly to distribute. (Flour, sugar, baking powder, salt).
2) Add in milk, butter, and vanilla. Stir until well mixed.
3) Beat in eggs.
4) Bake 20 mins or until toothpick comes out clean.

And so on (I won't write the complete reciepe It's a programming blog not your grandma's cookbook ;) !

Implemetation

In programming it means to choose a programming language and implement the Algorithm through code.

But in our last example it means implementing the instructions in real world not only on paper like writing the algorithm ( you got it , didn't you ? ).

Testing

Testing means to check if everything works right no unexpected syntax or locigal errors and if the program works right, you do this by doing trials with prepared outputs and check if your program behaviour meets the expected one.

In our case (making a cake) it means to check if the output is a cake not something else as a pie or something :) .

Program documentation

All steps taken for solving the problem that include: given Input, output, plan for solving the problem, drawn flowchart, programming language used for coding and, instructions, date of last modification of the program and, people who contribute to the program development process, to have the program documented to go back for feedback and correction.

The documentation is beneficial when more than one person participate in writing or modifying the program.

Conclusion

1) Algorithm is one of the essential steps to solve a problem
2) A problem is the computation we want to do , the task we need to complete, the output or objective we want to reach
3) Problem solving includes problem definition, algorithm preparation, implementation, testing and program documentation.

So that was it for this post , follow me if you want to see the rest of the series, if you like it react , and let me know in the comment section below.

Discussion (0)