39 lines
1.5 kB
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* strategies.h :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: ohaponiu <marvin@42.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2026/04/28 13:07:13 by ohaponiu #+# #+# */
9/* Updated: 2026/05/03 22:10:46 by ohaponiu ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#ifndef STRATEGIES_H
14# define STRATEGIES_H
15
16# include "types.h"
17
18void dispatch(t_context *ctx);
19
20/* O(1) */
21void sort_three(t_stack *a, t_ops *ops);
22void sort_five(t_stack *a, t_stack *b, t_ops *ops);
23
24/* O(n^2) */
25void sort_insert(t_stack *a, t_stack *b, t_ops *ops);
26
27/* O(n sqrt n) */
28void sort_chunk(t_stack *a, t_stack *b, t_ops *ops);
29
30/* O(n log n) */
31void sort_turk(t_stack *a, t_stack *b, t_ops *ops);
32
33/* utils */
34int find_extremum_pos(t_stack *s, int find_max);
35int find_insert_pos(t_stack *a, int val);
36void rotate_a_to_top(t_stack *a, int pos, t_ops *ops);
37void rotate_b_to_top(t_stack *b, int pos, t_ops *ops);
38
39#endif