summaryrefslogtreecommitdiff
path: root/sorting.c
diff options
context:
space:
mode:
authorDominik Kaiser2024-04-16 00:13:14 +0200
committerDominik Kaiser2024-04-16 00:13:14 +0200
commit4f288f94c8ec8ced5200d2e4e5713d9b119aed48 (patch)
tree4b812065facb59bd774d9b88a5ea2550b0f28ebd /sorting.c
parentf421b2dcf9a5d12655e48f4a06f35f17e785fb0f (diff)
downloadpush_swap-4f288f94c8ec8ced5200d2e4e5713d9b119aed48.tar.gz
push_swap-4f288f94c8ec8ced5200d2e4e5713d9b119aed48.zip
Revert "Add inefficient quicksort? algorithm"
This reverts commit f421b2dcf9a5d12655e48f4a06f35f17e785fb0f.
Diffstat (limited to 'sorting.c')
-rw-r--r--sorting.c44
1 files changed, 2 insertions, 42 deletions
diff --git a/sorting.c b/sorting.c
index b5668a9..f04304f 100644
--- a/sorting.c
+++ b/sorting.c
@@ -6,54 +6,14 @@
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/13 15:04:19 by dkaiser #+# #+# */
-/* Updated: 2024/04/15 23:39:57 by dkaiser ### ########.fr */
+/* Updated: 2024/04/15 17:54:23 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
-#include "libft/ft_printf.h"
-#include "libft/libft.h"
#include "push_swap.h"
-int is_sorted(t_stack *stack)
-{
- int i;
-
- if (stack->size < 2)
- return 1;
- i = 1;
- while (i < stack->size)
- {
- if (stack->stack[i] < stack->stack[i-1])
- return 0;
- i++;
- }
- return 1;
-}
-
t_list *stack_sort(t_stack *stack_a, t_stack *stack_b)
{
- t_list *cmds = NULL;
- int pivot;
-
- int pivot_idx = stack_a->size - 1;
- while (stack_b->size || !is_sorted(stack_a))
- {
- pivot = stack_a->stack[pivot_idx];
-
- while (stack_a->size > 0 && stack_a->stack[0] != pivot)
- {
- if (stack_a->stack[0] > pivot)
- run_command(stack_a, stack_b, &cmds, RA);
- else
- run_command(stack_a, stack_b, &cmds, PB);
- }
- while (stack_b->size > 0)
- run_command(stack_a, stack_b, &cmds, PA);
- if (stack_a->stack[pivot_idx] == pivot)
- pivot_idx--;
- if (pivot_idx < 0)
- pivot_idx = stack_a->size - 1;
- }
- return cmds;
+ return NULL;
}