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.

Various Sorting Algorithms

Sort Huge amount of data using C Programming Language

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.

Data Structures and Algorithm Analysis in Java

Data Structures and Algorithm Analysis in 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.

Algorithms in C

Algorithms in C

These algorithms are represented in terms of compact implementations in C so that readers can both understand their fundamental properties and implement them in real applications. The method of the analysis of algorithms is quite carefully designed. When appropriate, analytic results are described to explain why certain algorithms are preferred. In some cases, the practical algorithms’ relationship being discussed to purely theoretical results is also described.

Scroll to Top