C Fundamentals
Algorithms · data structures · cryptography · systems — pure C11, zero deps
Loading...
Searching...
No Matches
insertion_sort.c File Reference

Insertion sort — stable, O(n²) worst, O(n) on nearly-sorted input. More...

#include "sorts.h"
#include <string.h>

Go to the source code of this file.

Functions

void insertion_sort_ints (int *arr, size_t n)
 
void insertion_sort_strings (char **arr, size_t n)
 

Detailed Description

Insertion sort — stable, O(n²) worst, O(n) on nearly-sorted input.

Walk the array left-to-right; for each element, slide it leftward over any larger predecessors until it lands in its sorted slot.

Definition in file insertion_sort.c.

Function Documentation

◆ insertion_sort_ints()

void insertion_sort_ints ( int *  arr,
size_t  n 
)

Definition at line 25 of file insertion_sort.c.

Referenced by main().

◆ insertion_sort_strings()

void insertion_sort_strings ( char **  arr,
size_t  n 
)

Definition at line 12 of file insertion_sort.c.

Referenced by algo_from_name().