1. Searching Algorithms
Linear Search: Iteratively searches each element in the array.
Time Complexity: O(n)Binary Search: Compares the target with the middle element of a sorted array and narrows down the search.
Time Complexity: O(log₂n)
2. Sorting Algorithms
Bubble Sort: Swaps adjacent elements in repeated passes.
Time Complexity: O(n²)Insertion Sort: Inserts elements into their correct position in a sorted part of the array.
Time Complexity: O(n²)Selection Sort: Selects the smallest value from unsorted elements in each pass.
Time Complexity: O(n²)Heap Sort: Uses heaps to sort elements.
Time Complexity: O(n log n)Merge Sort: A divide-and-conquer algorithm that divides the array, sorts each half, and merges.
Time Complexity: O(n log n)Quick Sort: Uses a pivot to partition and recursively sort arrays.
Time Complexity: O(n log n) (average), O(n²) (worst case).
3. Basic Math Algorithms
- Euclid's Algorithm for GCD: Finds the greatest common divisor by division.
- Sieve of Eratosthenes: Identifies prime numbers by eliminating multiples.
- Bit Manipulations: Uses bitwise operators for low-level operations.
4. Graph Algorithms
- Breadth-First Search (BFS): Traverses level by level using a queue.
- Depth-First Search (DFS): Explores depth-wise using a stack. Time Complexity: O(V + E)
- D*ijkstra's Algorithm:* Finds the shortest path in a weighted graph.
5. Tree Algorithms
- Inorder Traversal: Left subtree → Root → Right subtree.
- Preorder Traversal: Root → Left subtree → Right subtree.
- Postorder Traversal: Left subtree → Right subtree → Root. Time Complexity: O(n)
- Kruskal's Algorithm: Finds the minimum spanning tree by adding edges in order of weight.
6. Dynamic Programming
- Floyd-Warshall Algorithm: Finds shortest paths between all pairs in a weighted graph. Uses Memoization (top-down) and Tabulation (bottom-up).
7. Backtracking Algorithms
- Solves problems like N-Queens, Sum of Subsets, Graph Coloring, and Hamiltonian Cycles.
8. Huffman Compression Algorithm
- Compresses data by building a Huffman tree and assigning codes to characters based on frequency.
Top comments (17)
These are incredibly specific - who on Earth is wasting their time writing a Huffman compressor in 2024? If I found one of my team doing that I'd be hauling them up and asking them why they feel we should take on the support burden of our own compression, what do we know that critically improves performance? In fact if I found them writing a sort algorithm I'd be wondering why. If knowing algorithms like this means you write the code for them in your day job, then there had better be a very good reason that tried and tested modules are not being used because otherwise the cost of support and mental effort are going to be entirely wasted.
I would. however, be very interested in someone who could explain why my team should know or apply the sieve of Eratosthenes or N-Queens algorithm to our code base, Kruskal's algorithm etc. If they could understand our code base and suggest significant improvements then that would be useful, but I'm not interviewing for that.
Well, you should learn these algorithms to learn something about algorithms and complexity.
While you need to use bit-manipulation from time to time (although I prefer not to), you shouldn't implement any sort or search algorithms yourself - except you create a standard library for a programming language.
It is good to know how to traverse a tree.
Also it is good to know how compression works, it may help you create data that ist better to compress.
And the other algorithms, are like the tree algorithms, you don't know you need them until you do. Also they may help you classify the problem you are trying to solve.
And about the sorting algorithm someone put in your codebase: I bet someone wrote it who just came from school, where they teach you all those basic algorithms, without telling you, that you will never ever need them in your professional career. Students don't know better.
I think you've made my point, many of these are academic to a large extent these days and most certainly aren't things you Must know. I wish more people would learn practical skills, so I didn't have to BootCamp it into them.
Agreed. There is value though to have such algorithms studied once Just to get a feel of the underlying logic and complexity. Only staying on the level of practical skills is maybe enough for making web sites but one needs a little deeper understanding when more complicated systems are built.
I completely agree! The real skill lies in understanding when and where to apply these algorithms effectively, rather than just implementing them from scratch. Practical application and optimization are what truly matter in real-world scenarios.
You don't learn or write these for your application but to build logics for complex problems. Just like a beginner starts with prime number or Fibonacci..
So, to be clear, we learn these algorithms so we can then not use them? Or at least most developers do not use them. I get it for computer science, but please don't come here, where many people have been through a BootCamp and tell them they must know this, it just isn't true.
I started my career in the last millenium and worked on platforms with very weak or non-existant standard libraries, so yeah, I've built low level code, sorts and the like. The world moved on, thankfully, and now I can spend my time solving actual problems that my customers have.
It might be helpful if you added something saying why you think these are important to know, or whether the benefit is in (since this is for #beginners) knowing in general how different algorithms work to solve seemingly similar problems or whether this is a cramming list for technical interviews.
Learning, I guess, "algorithmic thinking" (apologies but my education was last millennium and I don't know what the kids call it now) is an important skill for a lot of development tasks, but teaching it is much more involved than rote-learning a list of code snippets.
While I've had a couple of interviews where people have asked me to write a sorting algorithm from scratch that's suitable for a particular problem, I've generally used it as an opportunity to ask them why they want me to. Why the better answer wouldn't be to use an existing library function, and why it would be important to optimise for a specific algorithm. In the real world, search data often change, and marginal gains in one direction can flip over time. If the speed of a search is critical, then it's going to be 100% better to use an existing tool.
Must-know algorithms for which role?
These are useful! It would be nice to have an example function, but I know that would be complex. Good article!
Thanks.
Thanks for sharing with the community
welcome.
I just want to say , do not rewrite math as tree or something like that . the tree is probability on decision, it s advance topic of probability which have been simplified when CS growing. BackTrack is base on series number , searching base on mapping and organization ,dynamic from physic ( the key of dynamic is equation of system , Lagrange is easiest approach , then using math tool to solve it. ) . in computation, or in CS field people just describe math/physic /natural object/chemistry thought algorithm which computer can parse and convert it into binary to handle. That why in the first thing to be teach will be ASCI and binary. i have took around 2 month to learn about OP code and how computer can understand and calculation , actually computer dont understand anything unless people decode information to a scale (often binary )that computer can understand . in OP code and logic circuit, it show how computer calculation, adding , memory and so on . algorithm just a top-bottom approach, but i rarely to use it , instead i learn physic, math,and chemistry equation then one step on paper to convert as algorithm, the last step is programming. Simple , these topic already learn something in high school, i just expand it . so what is the bridge , it s math notation , the loop in programming is sum notation, a dummy notation is depend on equation, it some time stack index, sometime matrix,etc . and function is function. Mapping in graph or variable is scope/pineline , the key of map that it must follow 4 rules (read mapping on wiki)and it will be fine .
To sum of ,programming is easy ,if people understand math and hòw relationship of math between each field, just it . however it s too much and i feel burned out when working with its.
Very simple when describe CS field in math notation, very basic no abstraction. Science in CS alway be there ,do not forget.
Maybe extend the list with use cases. This is just sums a bunch of algoritmes. It does not teach anything
It would be unwise to ignore the study of algorithms, they are primitives in the domain of software engineering.
Think 😄😁
Some comments may only be visible to logged-in visitors. Sign in to view all comments.