From 6fb072f62c2f50118dd5cb377d10c76ece51e5fb Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Sun, 4 Oct 2020 14:36:07 +0200 Subject: Setze srcut-Marker... --- avl.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'avl.c') diff --git a/avl.c b/avl.c index 201dc5b..13a3d5f 100644 --- a/avl.c +++ b/avl.c @@ -1,15 +1,18 @@ // AVL Tree +#include #include #include -#include #include /* utils */ #include "util.h" -// TODO: [x] Review: http://www.inr.ac.ru/~info21/ADen/ -// [x] Tests: https://stackoverflow.com/q/3955680 +// clang-format off +// Review: http://www.inr.ac.ru/~info21/ADen/ +// Tests: https://stackoverflow.com/q/3955680 + +/* --8<-- avl_type */ typedef int T; struct tree_node { @@ -19,7 +22,9 @@ struct tree_node { int count; /* collision counter */ /* ggf. weitere Felder... */ }; +/* -->8-- */ +/* --8<-- avl_insert_r */ static struct tree_node * insert_r(T x, struct tree_node *p, bool *h) { @@ -109,14 +114,18 @@ insert_r(T x, struct tree_node *p, bool *h) ERROR("das hier sollte niemals passieren"); return p; } +/* -->8-- */ +/* --8<-- avl_insert */ struct tree_node * insert(struct tree_node *tree, T data) { bool h = false; return insert_r(data, tree, &h); } +/* -->8-- */ +/* --8<-- avl_balanceL */ static struct tree_node * balanceL(struct tree_node *p, bool *h) { @@ -157,7 +166,9 @@ balanceL(struct tree_node *p, bool *h) } return p; } +/* -->8-- */ +/* --8<-- avl_balanceR */ static struct tree_node * balanceR(struct tree_node *p, bool *h) { @@ -198,7 +209,9 @@ balanceR(struct tree_node *p, bool *h) } return p; } +/* -->8-- */ +/* --8<-- avl_del */ static void del(struct tree_node **q, struct tree_node **r, bool *h) { @@ -217,7 +230,9 @@ del(struct tree_node **q, struct tree_node **r, bool *h) *h = true; } } +/* -->8-- */ +/* --8<-- avl_delete_r */ static struct tree_node * delete_r(T x, struct tree_node *p, bool *h) { @@ -253,14 +268,16 @@ delete_r(T x, struct tree_node *p, bool *h) } return p; } +/* -->8-- */ +/* --8<-- avl_delete */ struct tree_node * delete(struct tree_node *tree, T data) { bool h = false; return delete_r(data, tree, &h); } - +/* -->8-- */ // aux display and verification routines, helpful but not essential struct trunk { -- cgit v1.3