Data Structures Lerax  v3.0-104-ge031
Opinionated Data Structures & Algorithms
Loading...
Searching...
No Matches
sort.h
Go to the documentation of this file.
1
12
13#ifndef SORT_H
14#define SORT_H
15
16#ifndef Type
17#define Type int
18#endif
19#ifndef TypeFormat
20#define TypeFormat "%d"
21#endif
22
23/**********************/
24/* SORTING ALGORITHMS */
25/**********************/
26
35void bubblesort(Type *v, int n);
36
45void insertionsort(Type *v, int n);
46
55void mergesort(Type *v, int n);
56
65void quicksort(Type *v, int n);
66
75void heapsort(Type *v, int n);
76
85void radixsort(Type *v, int n);
86
95void selectionsort(Type *v, int n);
96
97/*********/
98/* UTILS */
99/*********/
100
101
108void print_vector(Type *v, int n);
109
110
117void swap(Type *e1, Type *e2);
118
126int check_sorted(Type *v, int n);
127
135
143void debug_print_vector(Type *v, int n);
144
151void debug(const char *format, ...);
152
153#endif
void bubblesort(Type *v, int n)
Sorts an array of integers in ascending order using the bubble sort algorithm.
void quicksort(Type *v, int n)
Sorts an array of integers in ascending order using the quicksort algorithm.
void insertionsort(Type *v, int n)
Sorts an array of integers in ascending order using the insertion sort algorithm.
void selectionsort(Type *v, int n)
Sorts an array of integers in ascending order using the selection sort algorithm.
void radixsort(Type *v, int n)
Sorts an array of integers in ascending order using the radix sort algorithm.
void heapsort(Type *v, int n)
Sorts an array of integers in ascending order using the heapsort algorithm.
void mergesort(Type *v, int n)
Sorts an array of integers in ascending order using the merge sort algorithm.
void print_vector(Type *v, int n)
Prints the elements of an array to the console.
Type * random_vector(int n)
Creates an array of random integers.
void swap(Type *e1, Type *e2)
Swaps the values of two integers.
int check_sorted(Type *v, int n)
Checks if an array is sorted in ascending order.
void debug(const char *format,...)
Prints a debug message to the console if the DEBUG symbol is defined.
#define Type
Definition sort.h:17
void debug_print_vector(Type *v, int n)
Prints the elements of an array to the console if the DEBUG symbol is defined.