Algorithms Tutorials — Implementation in C, Data Structures and Algorithm Libraries

Flat diagram illustration showing sorting algorithm bar chart binary search tree and weighted graph network for algorithms tutorials in blue and white

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 the data structures those algorithms are built on, each explained and implemented in code you can compile and study.

Each tutorial explains how the algorithm works, analyses its time and space complexity, and includes working source code you can compile and study. The refreshed tutorials go further: the code is compiled and run for the article, its output is shown as captured, and the source and tests are on GitHub. Whether you are preparing for technical interviews, studying computer science fundamentals or optimising production code — start here.

What You’ll Learn

  • Sorting algorithms — bubble sort, selection sort, insertion sort, Shell sort, merge sort, quicksort and heap sort, each explained step by step with complexity analysis and working code in C and C++
  • Recursion and dynamic programming — the Towers of Hanoi, the Fibonacci series with memoization and the 0/1 knapsack problem: solving a problem through smaller copies of itself, and storing results so they are not computed twice
  • Graph and number algorithms — Kruskal’s minimum spanning tree and prime number programs from trial division to the Sieve of Eratosthenes and Miller–Rabin
  • Data structures for algorithms — arrays, linked lists, stacks, tries and binary trees, the building blocks the algorithms above rely on
  • Data structures for algorithms — arrays, linked lists, stacks, queues, binary trees and hash tables as the building blocks for efficient algorithm implementation in C and C++
  • Algorithm complexity and analysis — understanding Big O notation, time and space complexity, best and worst case analysis and choosing the right algorithm for your specific problem
  • C algorithm libraries — when to call qsort(), std::sort or std::stable_sort instead of writing your own, what each one does and does not guarantee, and how they compare with hand-written sorts in the sorting algorithms comparison

Why MYCPLUS: Trusted by programmers and computer science students since 2004 — the algorithm tutorials pair each explanation with complexity analysis and source code, and the refreshed ones are compiled, run and tested for the article.

Scroll to Top