#ifndef INC_LIB_ALGO_AVL_TREE_H #define INC_LIB_ALGO_AVL_TREE_H #include #include #include #include struct AVLNode { void* data; bool_t (*compare)(void*, void*); struct AVLNode* left; struct AVLNode* right; uint8_t height; }; // Get the height of an AVL node uint8_t get_height(struct AVLNode* node); // Get the Maximum Height between two uint8_t max_height(uint8_t a, uint8_t b); // Get the balance factor of a node ssize_t get_balance_factor(struct AVLNode* node); // Rotate an AVL node right struct AVLNode* right_rotate(struct AVLNode* parent); // Rotate an AVL node left struct AVLNode* left_rotate(struct AVLNode* parent); // In-order traversal print pointer void print_in_order(struct AVLNode* root); // Free avl tree nodes starting at root void free_avl_tree(struct AVLNode* root); // Free avl tree and their data starting at root void free_avl_tree_nodes(struct AVLNode* root); #endif