-
Notifications
You must be signed in to change notification settings - Fork 0
/
sort.h
70 lines (45 loc) · 1.67 KB
/
sort.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef _SORT_H_
#define _SORT_H_
#include <stdio.h>
#include <stdlib.h>
/* STRUCTURES DEFINITION */
/**
* struct listint_s - Doubly linked list node
*
* @n: Integer stored in the node
* @prev: Pointer to the previous element of the list
* @next: Pointer to the next element of the list
*/
typedef struct listint_s
{
const int n;
struct listint_s *prev;
struct listint_s *next;
} listint_t;
/* STRUCTURES FOR LAST ADVANCED TASK (deck_sort) */
/* FUNCTION PROTOTYPES */
void print_array(const int *array, size_t size);
void print_list(const listint_t *list);
void bubble_sort(int *array, size_t size);
void insertion_sort_list(listint_t **list);
void selection_sort(int *array, size_t size);
void quick_sort(int *array, size_t size);
void shell_sort(int *array, size_t size);
void cocktail_sort_list(listint_t **list);
void counting_sort(int *array, size_t size);
void merge_sort(int *array, size_t size);
void heap_sort(int *array, size_t size);
void radix_sort(int *array, size_t size);
void bitonic_sort(int *array, size_t size);
void quick_sort_hoare(int *array, size_t size);
/* My helper functions */
void swap_nodes(listint_t **, listint_t *, listint_t *);
void recursive_call(int *array, size_t size, int low, int high);
int partition(int *array, size_t size, int low, int high);
void faviswap(int *, int *);
void sift_down(int *array, size_t size, size_t index, size_t size2);
void bitonic_sort_rec(int *array, size_t size, int dir, size_t size_total);
void bitonic_merge(int *array, size_t size, int dir, size_t size_total);
void merge_sort_rec(int *array, size_t size, int *temp);
void merge(int *array, size_t size, size_t mid, int *tmp);
#endif /* _SORT_H_ */