This repository contains implementations of various binary tree data structures and algorithms in C. It includes functionalities such as insertion, deletion, traversal methods (inorder, preorder, postorder), and search operations.
The Binary Trees project aims to provide a comprehensive collection of binary tree implementations to facilitate learning and usage of fundamental data structures and algorithms. Each implementation is designed to be efficient and robust, showcasing best practices in C programming.
- Binary Tree Implementations: Includes basic binary tree, binary search tree (BST), AVL tree, and more.
- Core Operations: Supports common operations such as insertion, deletion, and various traversal methods.
- Efficient Algorithms: Algorithms are optimized for performance and adhere to standard data structure principles.
- Detailed Documentation: Each function and data structure is thoroughly documented for ease of understanding and usage.
To use the binary trees in your projects, follow these steps:
-
Clone the repository:
git clone https://github.com/Gasimhacker/binary_trees.git
-
Navigate to the directory:
cd binary_trees -
Include in Your Project: In your project directory, create a new C file and include the header file binary_trees.h to access the functions and data structures from this repository.
#include <stdlib.h> #include <stdio.h> #include "binary_trees.h" /** * main - Entry point * * Return: Always 0 (Success) */ int main(void) { binary_tree_t *root; root = binary_tree_node(NULL, 98); root->left = binary_tree_node(root, 12); root->right = binary_tree_node(root, 402); binary_tree_print(root); printf("\n"); binary_tree_insert_left(root->right, 128); binary_tree_insert_left(root, 54); binary_tree_print(root); return (0); }
-
Compile the code (example using gcc):
gcc -Wall -Wextra -Werror -pedantic binary_tree_print.c 1-main.c 1-binary_tree_insert_left.c 0-binary_tree_node.c -o 1-left
-
Run the executable:
./1-left
There are no additional dependencies required to run the binary tree implementations other than a standard C compiler (e.g., gcc).
Contributions are welcome! Feel free to fork the repository and submit pull requests with your enhancements.