-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpick_sort.c
36 lines (33 loc) · 1.38 KB
/
pick_sort.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pick_sort.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: denizozd <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/13 14:55:55 by denizozd #+# #+# */
/* Updated: 2024/05/25 17:45:42 by denizozd ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
/* Selects the sorting algorithm based on the size of the linked list. */
t_node *pick_sort(t_node *stack_a)
{
t_node *stack_b;
int size_a;
stack_b = NULL;
size_a = stack_size(stack_a);
if (size_a < 2)
return (stack_a);
if (size_a == 2)
return (sort_2(stack_a));
if (size_a == 3)
return (sort_3(stack_a));
if (size_a == 4)
return (sort_4(stack_a, stack_b));
if (size_a == 5)
return (sort_5(stack_a, stack_b));
if (size_a > 5)
return (sort_big(stack_a, stack_b));
return (0);
}