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.
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
Youβll need a C compiler like gcc
.
- 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).
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.
AbegΓ Razafindratelo