10 Algorithms Every Developer Should Learn
Tags: algorithms, javascript, datascience, tutorial
Published: 2023-06-08 00:28:49

There seems to be a large misconception from a lot of aspiring devs that memorizing standard algorithms is important. Now for some job interviews that may be the case, but it is not particularly important for actually being a successful developer.

So are the things you learn in an algorithm class useless? Absolutely not. What is incredibly important is the ability to think algorithmically. Not just so that you can reproduce and altar standard algorithms, but so that you are comfortable using code to solve whatever problems you encounter as a dev.

That’s why we’ve assembled a list of 10 algorithms that aspiring devs should work-through to get comfortable with thinking algorithmically.

**1. Binary Search**
Binary search is one of the first things taught in any computer science class. It is perhaps the simplest example of how a little bit of ingenuity can make things, quite literally, exponentially more efficient.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1y95bm23xvw58i6l4c8d.png)

A binary search consists of taking a sorted array, and iteratively splitting the array into two and comparing an element that you are looking for against each half, until you find the element.

**2. Selection, Bubble, and Insertion Sort**
Sorting algorithms are one of the most fundamental tools that a developer should have in their arsenal. Selection, Bubble, and Insertion sort are some of the first that new developers should work through. In any scenario when speed matters you’re not going to be using these algorithms but working with them is a great introduction to array traversal and manipulation.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qbfq8ruge9l1g5ivjb0g.png)

**3. Quicksort and Mergesort**
Similar to #2, sorting algorithms are great for getting comfortable with arrays, but Quicksort and Mergesort are efficient enough to be used in serious applications. Being comfortable implementing these sorting algorithms(Note ‘Being comfortable’ and not ‘memorizing’) these algorithms are essential to being a serious developer.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9b68qgk87nqf52sk533w.png)



**4. Huffman Coding**
Huffman coding is the foundation of modern text compression. It works by considering how often different characters appear in a text, and organizes them in a tree based on this frequency.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kk9jolfgnea9kqr5kst7.png)

Taking the time to work with Huffman coding is a great way to get comfortable with data representation and tree traversal, which are two of the most important issues that computer scientists need to be able to grapple with.

**5. Breadth First Search**
Again, trees turn out to be at the heart of a lot of algorithms and software that developers work with. As such, understanding basic tree traversal is a top priority for an aspiring developer.

Breadth first search works by exploring a tree level by level until the target node is found. Since it literally going through every level it is guaranteed to find a solution

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a9ttxm5pn09lcfiiur3q.png)

**6. Depth First Search**
Continuing with tree traversal, Depth-First Search is the other main approach for finding an element in a tree. Instead of working down the tree level by level, it explores the tree branch by branch.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tg9jp6skpnly0w1b2e3w.png)

Now assuming it does not have infinitely extended branches, DFS will similarly always work. Implementing these two search algorithms aren’t particularly complex, but what is incredibly important is learning when to use one over the other. A lot of software design is being able to understand the structure of the information you are working with, and pick algorithms that optimize for that structure.

**7. Gradient Descent**
Now for a lot of developers, Gradient Descent is not necessarily going to be useful. If, however, you are touching anything with regression or machine learning, Gradient Descent is going to be at the heart of your work.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/swqxymtcsrobnk81jain.png)

Gradient Descent is a method of procedure optimizing functions using calculus. In the context of regression and machine learning, this means finding specific values that minimize the error in your prediction algorithm. While it is certainly more mathematically involved that a lot of these other algorithms, if you are working significantly with data and predictions, understanding how gradient descent works is incredibly important.


**8. Dijkstra’s Algorithm**
Another incredibly important issue that developers work with is path finding. Graphs turn out to be an incredibly versatile way to describe all kinds of problems that involve networks of distinct objects.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rvjtfepthp7jdb8d5560.png)

Dijkstra’s algorithm is a way of finding the quickest path between two nodes in a graph. It is the foundation of most work done in path-finding and finds itself used in anything from artificial intelligence to game design.

**9. Diffie-Helllman Key Exchange**
The Diffie-Hellman Key Exchange is a great introduction to how cryptography tends to work. More specifically, a Diffie-Hellman Key Exchange works by combining public and private keys(Which are effectively long numbers) to encrypt information when it is being transferred between different parties.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p7x5stbqj08jxnomhh4v.png)

Even if you’re not working in cybersecurity, having a working understanding of encryption and secure communication is incredibly important to working as a developer. Additionally, even though Diffie-Helman is far from the best algorithm, it is incredibly easy to implement and is similar enough to most other encrypted communication methods.

**10. Doing Practice Problems**
These first nine algorithms all gave you ways to solve archetypes of problems you might encounter as a developer. The reality, however, is that as a developer you are often going to be encountering algorithmic problems that are completely new. That’s why more important than memorizing any algorithm, is developing the ability to solve problems algorithmically.

Luckily, there is no shortage of websites to practice. Some of our favorites are:

https://leetcode.com/
https://projecteuler.net/(More mathematical)
https://www.hackerrank.com/
These are great environments to find difficult, yet fulfilling algorithmic problems and hone your skills.