special sort for 5 ok
This commit is contained in:
21
srcs/algo.c
21
srcs/algo.c
@@ -1,22 +1,5 @@
|
||||
#include "push_swap.h"
|
||||
|
||||
// size is initialized to 1 because the loop check the next element, so it will end one step before reaching it
|
||||
// it checks the next one to avoid handle the first one with ->limit set to 1
|
||||
int sublist_size(t_stack *list)
|
||||
{
|
||||
int size;
|
||||
|
||||
if (list == NULL)
|
||||
return (0);
|
||||
size = 1;
|
||||
while (list->next != NULL && list->next->limit != 1)
|
||||
{
|
||||
list = list->next;
|
||||
size++;
|
||||
}
|
||||
return (size);
|
||||
}
|
||||
|
||||
int nbr_element_smaller(t_stack *list, int size, int pivot)
|
||||
{
|
||||
int nbr;
|
||||
@@ -126,7 +109,7 @@ void recursif_sort(t_stack **a, t_stack **b, t_list *solution)
|
||||
else
|
||||
{
|
||||
|
||||
// sort_big(a, b, solution)
|
||||
// bubble_sort(a, b, solution)
|
||||
mini_sort(a, solution);
|
||||
// minisort(a, solution);
|
||||
if (sublist_size(*b) > 4)
|
||||
@@ -143,10 +126,8 @@ void hugo_sort(t_stack **a, t_stack **b, t_list *solution)
|
||||
{
|
||||
if (sublist_size(*a) <= 3)
|
||||
special_sort_3(a, solution);
|
||||
/*
|
||||
else if (sublist_size(*a) <= 5)
|
||||
special_sort_5(a, b, solution);
|
||||
*/
|
||||
else
|
||||
recursif_sort(a, b, solution);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user