DEV Community

Tadea Simunovic
Tadea Simunovic

Posted on • Edited on

Algorithms

An algorithm is a set of instructions designed to perform a specific task.
In a world of computer science, it's just a fancy word for code. An example of the basic code that returns the average from a list of integers is an algorithm.

function getAverage(list) {
    int sum = 0, count = list.length;
    for (var i = 0; i < count; i++) {
        sum += list[i];
    }
    return sum/count;
}
Enter fullscreen mode Exit fullscreen mode

For example, a non-internet based algorithms would be something like a recipe for bread. You start with the following set of instructions on how to put all ingredients together and get the final product.

On the other side with algorithms is the same, a set of instructions that enable the computer program to put together different sources of information and generate results.

There are often many different algorithms ways to accomplish any given task. Each algorithm has advantages and disadvantages in different situations. Sorting is one place where a lot of research has been done because computers spend a lot of time sorting lists. Here are five different algorithms that are used in sorting:
1. Bin sort
2. Merge sort
3. Bubble sort
4. Shell sort
5. Quicksort

If you are familiar with any programming language you should base on that language, it will help you to be more comfortable to understand.
For example, Python because it has a relatively shallow learning curve, allowing new programmers to focus more on the logical/problem-solving aspect of programming instead of syntax. Javascript another great choice but it becomes steeper as you get into some of the more advanced topics.

Programming languages are tools that developers use to solve problems. How are you even expected to solve a problem effectively if you don’t know how to use the tools to solve problems?

So why algorithms?
They give the programmer the power to implement efficient, reliable, and fast code in a shorter amount of time.

Practice, practice, and practice! This is the best way of learning.

Check this link for beginner-friendly algorithms challenges.
HackerRank Algorithms

Top comments (0)