diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-10-11 22:19:00 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-10-11 22:19:00 +0200 |
| commit | 73c2b00a10c5786ddeeacc915e233fd4df1c9321 (patch) | |
| tree | e299ea4e8ac161b2b21170172ff8f182c1c3fe1a /rushs/tinyprintf/binary_tree_dynamic/binary_tree.c | |
| parent | c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (diff) | |
fix: evalexpr & tinyprintf contenaient toute la piscine
Diffstat (limited to 'rushs/tinyprintf/binary_tree_dynamic/binary_tree.c')
| -rw-r--r-- | rushs/tinyprintf/binary_tree_dynamic/binary_tree.c | 95 |
1 files changed, 0 insertions, 95 deletions
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 <stddef.h> -#include <stdio.h> - -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); -} |
