Top 10 Algorithms Every Programmer Should Know (With Code and Complexity)
At n = 1,000,000, O(log n) takes 20 steps and O(n squared) takes a trillion. The ten families that matter, with complexity for each.
Algorithms are the foundation of all software — the precise, step-by-step instructions that tell a computer how to solve a problem efficiently. Understanding algorithms is not just an academic exercise. It is what separates programmers who write code that works from engineers who write code that works fast, scales under load and handles complex problems elegantly. From sorting a list of names to finding the shortest path across a network, algorithms determine how well your software performs in the real world.
MYCPLUS has been publishing algorithm tutorials and implementation guides since 2004, with a particular focus on practical algorithm implementations in C and C++. This section covers the essential algorithms every programmer should understand — sorting, searching, graph traversal, tree operations and optimisation techniques — alongside practical data structure implementations and guides to established algorithm libraries used in professional C and C++ development.
With over 30 articles covering beginner through advanced algorithm concepts, you will find clear explanations of how each algorithm works, analysis of time and space complexity, working C source code implementations you can compile and study, and practical guides to algorithm libraries that save development time on real projects. Whether you are preparing for technical interviews, studying computer science fundamentals or optimising production code — start here.
Why MYCPLUS: Trusted by programmers and computer science students since 2004 — every algorithm tutorial includes working C source code implementations, complexity analysis and practical examples designed for both academic study and real-world software development.
At n = 1,000,000, O(log n) takes 20 steps and O(n squared) takes a trillion. The ten families that matter, with complexity for each.
On 5,000 sorted values a last-element pivot makes 12.5 million comparisons instead of 67,000. Quicksort, measured — with code in five languages.
Kruskal’s algorithm builds a minimum spanning tree by sorting edges and rejecting cycles with union-find. Tested C, C++, and Python code included.
Shell Sort improves insertion sort by sorting far-apart elements first. See how it works, why gap sequences matter, and tested code in five languages.
Coding competitions are the fastest way to sharpen your problem-solving skills. Here are the best competitive programming platforms and contests to enter in 2026, for every level.
In a lot of programs my gensort-utility turned out to be very useful. It consists simply of the header file
The big sort routine implements a way to sort huge amounts of data using C programming language. It sorts the data that do not fit into main memory by using a multi-phase sorting on files. It is a implementation from the book “Algorithms and data structures” by Niklaus Wirth. Additionally, this routine recognizes small amounts of data that do fit into memory and resorts to a in-place quicksort.
This article is about a collection of common Computer Science algorithms which may be used in C projects. The C Programming Language has a much smaller Standard Library as compared to other more modern programming languages such as Java or Python. The library provides a basic set of mathematical functions, string manipulation, type conversions, and file and console-based I/O.
Stanford Engineering Everywhere (SEE) offers few computer science courses to students online and at no charge. Programming Abstractions course covers advanced programming topics such as recursion, algorithmic analysis, and data abstraction using the C++ programming language, which is similar to both C and Java.
Delve into the fundamentals of data structures and algorithms with Data Structures and Algorithm Analysis in Java. This comprehensive guide focuses on performance optimization, scalability, and real-world Java implementations. From sorting to dynamic programming, it equips developers with the tools to build efficient, high-performance applications. A must-read for students and professionals seeking to master Java’s capabilities in solving complex computational problems.
Master efficient coding with Data Structures and Algorithm Analysis in C++ – your ultimate guide to building high-performance software solutions!
This Java Program solves the Towers of Hanoi problem for a tower of 10 disks. Ten differently-sized disks are stacked in a pile, in order of decreasing size. There are two other places for piles. The object is to move the pile to the second available place, subject to the rules that only one disk at a time can be moved, and no disk can be piled on top of a smaller disk. The Towers of Hanoi problem is a standard example of recursion.