Insertion sort algorithm implementation.
More...
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
|
void | RecursionInsertionSort (int *arr, int size) |
| Insertion sort algorithm implements using Recursion.
|
|
static void | test () |
| Test function.
|
|
int | main (int argc, const char *argv[]) |
| Main function.
|
|
Insertion sort algorithm implementation.
◆ main()
int main |
( |
int |
argc, |
|
|
const char * |
argv[] |
|
) |
| |
Main function.
- Returns
- integer 0
66{
67
68 srand(time(NULL));
70 return 0;
71}
static void test()
Test function.
Definition insertion_sort_recursive.c:44
◆ test()
static void test |
( |
void |
| ) |
|
|
static |
Test function.
- Returns
- None
45{
46 const int size = rand() % 500;
47 int *arr = (
int *)
calloc(size,
sizeof(
int));
48
49
50 for (int i = 0; i < size; i++)
51 {
52 arr[i] = (rand() % 100) - 50;
53 }
55 for (int i = 0; i < size ; ++i)
56 {
57 assert(arr[i] <= arr[i + 1]);
58 }
60}
void RecursionInsertionSort(int *arr, int size)
Insertion sort algorithm implements using Recursion.
Definition insertion_sort_recursive.c:20
#define free(ptr)
This macro replace the standard free function with free_dbg.
Definition malloc_dbg.h:26
#define calloc(elemCount, elemSize)
This macro replace the standard calloc function with calloc_dbg.
Definition malloc_dbg.h:22