From 73c2b00a10c5786ddeeacc915e233fd4df1c9321 Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Sat, 11 Oct 2025 22:19:00 +0200 Subject: fix: evalexpr & tinyprintf contenaient toute la piscine --- rushs/tinyprintf/binary_tree_dynamic/Makefile | 15 ---- rushs/tinyprintf/binary_tree_dynamic/binary_tree.c | 95 ---------------------- rushs/tinyprintf/binary_tree_dynamic/binary_tree.h | 22 ----- .../binary_tree_dynamic/binary_tree_print.c | 40 --------- 4 files changed, 172 deletions(-) delete mode 100644 rushs/tinyprintf/binary_tree_dynamic/Makefile delete mode 100644 rushs/tinyprintf/binary_tree_dynamic/binary_tree.c delete mode 100644 rushs/tinyprintf/binary_tree_dynamic/binary_tree.h delete mode 100644 rushs/tinyprintf/binary_tree_dynamic/binary_tree_print.c (limited to 'rushs/tinyprintf/binary_tree_dynamic') diff --git a/rushs/tinyprintf/binary_tree_dynamic/Makefile b/rushs/tinyprintf/binary_tree_dynamic/Makefile deleted file mode 100644 index 7fa9879..0000000 --- a/rushs/tinyprintf/binary_tree_dynamic/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -CC = gcc -CFLAGS = -Wall -Werror -Wvla -Wextra -std=c99 -pedantic - -SRC = binary_tree.c binary_tree_print.c -OBJ = $(SRC:.c=.o) - -.PHONY: library clean - -library: $(OBJ) - ar csr libbinary_tree.a $(OBJ) - -$(OBJ): $(SRC) - -clean: - $(RM) libbinary_tree.a $(OBJ) diff --git a/rushs/tinyprintf/binary_tree_dynamic/binary_tree.c b/rushs/tinyprintf/binary_tree_dynamic/binary_tree.c deleted file mode 100644 index 6d99e99..0000000 --- a/rushs/tinyprintf/binary_tree_dynamic/binary_tree.c +++ /dev/null @@ -1,95 +0,0 @@ -#include "binary_tree.h" - -#include -#include - -int size(const struct binary_tree *tree) -{ - if (tree == NULL) - return 0; - - return 1 + size(tree->left) + size(tree->right); -} - -static int max(int a, int b) -{ - if (a > b) - return a; - return b; -} - -int height(const struct binary_tree *tree) -{ - if (tree == NULL) - { - return -1; - } - - return 1 + max(height(tree->left), height(tree->right)); -} - -int is_perfect(const struct binary_tree *tree) -{ - if (tree == NULL) - return 1; - return height(tree->left) == height(tree->right) && is_perfect(tree->right) - && is_perfect(tree->right); -} - -int is_complete(const struct binary_tree *tree) -{ - if (tree == NULL) - { - return 1; - } - - int hg = height(tree->left); - int hd = height(tree->right); - - if (hg - hd != 0 && hg - hd != 1) - { - return 0; - } - - return is_complete(tree->left) && is_complete(tree->right); -} - -int is_degenerate(const struct binary_tree *tree) -{ - if (tree == NULL) - { - return 1; - } - - if (tree->left && tree->right) - { - return 0; - } - return is_degenerate(tree->left) && is_degenerate(tree->right); -} - -int is_full(const struct binary_tree *tree) -{ - if (tree == NULL) - return 1; - if ((tree->left && !tree->right) || (!tree->left && tree->right)) - return 0; - return is_full(tree->right) && is_full(tree->left); -} - -static int is_bzt(const struct binary_tree *tree, int min, int max) -{ - if (tree == NULL) - return 1; - if (tree->data > max || tree->data <= min) - return 0; - return is_bzt(tree->left, min, tree->data) - && is_bzt(tree->right, tree->data, max); -} - -int is_bst(const struct binary_tree *tree) -{ - if (tree == NULL) - return 1; - return is_bzt(tree, -2147483647, 2147483647); -} diff --git a/rushs/tinyprintf/binary_tree_dynamic/binary_tree.h b/rushs/tinyprintf/binary_tree_dynamic/binary_tree.h deleted file mode 100644 index a08e4ef..0000000 --- a/rushs/tinyprintf/binary_tree_dynamic/binary_tree.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef BINARY_TREE_H -#define BINARY_TREE_H - -struct binary_tree -{ - int data; - struct binary_tree *left; - struct binary_tree *right; -}; - -int size(const struct binary_tree *tree); -int height(const struct binary_tree *tree); -void dfs_print_prefix(const struct binary_tree *tree); -void dfs_print_infix(const struct binary_tree *tree); -void dfs_print_postfix(const struct binary_tree *tree); -int is_perfect(const struct binary_tree *tree); -int is_complete(const struct binary_tree *tree); -int is_degenerate(const struct binary_tree *tree); -int is_full(const struct binary_tree *tree); -int is_bst(const struct binary_tree *tree); - -#endif /* !BINARY_TREE_H */ diff --git a/rushs/tinyprintf/binary_tree_dynamic/binary_tree_print.c b/rushs/tinyprintf/binary_tree_dynamic/binary_tree_print.c deleted file mode 100644 index bce0f77..0000000 --- a/rushs/tinyprintf/binary_tree_dynamic/binary_tree_print.c +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include - -#include "binary_tree.h" - -void dfs_print_prefix(const struct binary_tree *tree) -{ - if (tree == NULL) - { - return; - } - - printf("%d ", tree->data); - dfs_print_prefix(tree->left); - dfs_print_prefix(tree->right); -} - -void dfs_print_infix(const struct binary_tree *tree) -{ - if (tree == NULL) - { - return; - } - - dfs_print_infix(tree->left); - printf("%d ", tree->data); - dfs_print_infix(tree->right); -} - -void dfs_print_postfix(const struct binary_tree *tree) -{ - if (tree == NULL) - { - return; - } - - dfs_print_postfix(tree->left); - dfs_print_postfix(tree->right); - printf("%d ", tree->data); -} -- cgit v1.2.3