GitHunt
AB

Abega1642/sorting-algorithms

๐Ÿ”ง Educational C implementations of classic sorting algorithms: Bubble, Insertion, Selection, and Substitution sorts.

Sorting Algorithms in C

This repository contains C implementations of fundamental sorting algorithms, including:

  • ๐Ÿ” Bubble Sort
  • ๐Ÿงฉ Insertion Sort
  • ๐Ÿ“ฅ Selection Sort
  • ๐Ÿ”„ Substitution Sort

Each algorithm is implemented in a clean and understandable way, intended for educational purposes and for those who want to better understand the mechanics of sorting at a low level.

๐Ÿ“ Structure

The repository is organized as follows:

sort-algorithms/
โ”‚
โ”œโ”€โ”€ include/                  
โ”‚   โ”œโ”€โ”€ bubble_sort.h
โ”‚   โ”œโ”€โ”€ selection_sort.h
โ”‚   โ”œโ”€โ”€ substitution_sort.h
โ”‚   โ”œโ”€โ”€ insertion_sort.h
โ”‚   โ”œโ”€โ”€ test_bubble_sort.h
โ”‚   โ”œโ”€โ”€ test_selection_sort.h
โ”‚   โ”œโ”€โ”€ test_substitution_sort.h
โ”‚   โ”œโ”€โ”€ test_insertion_sort.h
โ”‚   โ””โ”€โ”€ util.h
โ”‚
โ”œโ”€โ”€ src/                         # Source implementations
โ”‚   โ”œโ”€โ”€ bubble_sort.c
โ”‚   โ”œโ”€โ”€ selection_sort.c
โ”‚   โ”œโ”€โ”€ substitution_sort.c
โ”‚   โ””โ”€โ”€ insertion_sort.c
โ”‚
โ”œโ”€โ”€ tests/                       # Unit tests
โ”‚   โ”œโ”€โ”€ main_test.c
โ”‚   โ”œโ”€โ”€ test_bubble_sort.c
โ”‚   โ”œโ”€โ”€ test_selection_sort.c
โ”‚   โ”œโ”€โ”€ test_substitution_sort.c
โ”‚   โ””โ”€โ”€ test_insertion_sort.c
โ”‚
โ”œโ”€โ”€ README.md                    # Project overview, usage, build instructions
โ””โ”€โ”€ CMakefileLists.txt

๐Ÿš€ Getting Started

โœ… Prerequisites

Youโ€™ll need a C compiler like gcc.

๐Ÿง  Algorithms Explained

  • Bubble Sort: Repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order.
  • Insertion Sort: Builds the sorted array one item at a time by comparing with the left side.
  • Selection Sort: Repeatedly selects the smallest element and moves it to the sorted part.
  • Substitution Sort: (Custom or lesser-known algorithm โ€” clarify implementation details here if applicable).

๐Ÿ“š Educational Purpose

This project is designed to:

  • Help students understand core sorting algorithms.
  • Provide a playground to test and visualize sorting behavior.
  • Encourage algorithm comparison and performance analysis.

๐Ÿง‘โ€๐Ÿ’ป Author

Abegร  Razafindratelo