Welcome to the Binary Trees repository. This repository contains implementations of binary trees in C, a fundamental data structure in computer science.
In this repository, you'll find C programs that demonstrate various operations and algorithms related to binary trees. Binary trees are hierarchical data structures that are widely used in computer science for tasks like sorting, searching, and organizing data efficiently.
Before you can use the programs in this repository, you'll need to compile them. Here are the steps to get started:
- Clone this repository to your local machine using the following command:
git clone https://github.com/iakev/binary_trees.git
- Navigate to the cloned repository:
cd binary_trees
- Compile the desired program using a C compiler (e.g., GCC). Replace
program.c
with the name of the program you want to compile, andoutput
with your desired output filename:
gcc -Wall -Werror -Wextra -pedantic program.c -o output
- Execute the compiled program:
./output
Below are the C programs in this repository along with their descriptions:
This program defines a function binary_tree_node
that creates a new binary tree node.
This program defines a function binary_tree_insert_left
that inserts a new node as the left-child of a given node in a binary tree.
This program defines a function binary_tree_insert_right
that inserts a new node as the right-child of a given node in a binary tree.
This program defines a function binary_tree_delete
that deletes an entire binary tree.
This program defines a function binary_tree_is_leaf
that checks if a node in a binary tree is a leaf node.
This program defines a function binary_tree_is_root
that checks if a node in a binary tree is the root node.
This program defines a function binary_tree_preorder
that traverses a binary tree in pre-order (root-left-right) and applies a function to each node.
This program defines a function binary_tree_inorder
that traverses a binary tree in-order (left-root-right) and applies a function to each node.
This program defines a function binary_tree_postorder
that traverses a binary tree in post-order (left-right-root) and applies a function to each node.
This program defines a function binary_tree_height
that measures the height of a binary tree.
This program defines a function binary_tree_depth
that measures the depth of a node in a binary tree.
This program defines a function binary_tree_size
that calculates the size (number of nodes) of a binary tree.
This program defines a function binary_tree_leaves
that counts the leaves in a binary tree.
This program defines a function binary_tree_nodes
that counts the nodes with at least one child in a binary tree.
This program defines a function binary_tree_balance
that computes the balance factor of a binary tree.
This program defines a function binary_tree_is_full
that checks if a binary tree is a full binary tree.
This program defines a function binary_tree_is_perfect
that checks if a binary tree is a perfect binary tree.
This program defines a function binary_tree_sibling
that finds the sibling of a given node in a binary tree.
This program defines a function binary_tree_uncle
that finds the uncle of a given node in a binary tree.
This program defines a function binary_trees_ancestor
that finds the lowest common ancestor of two nodes in a binary tree.
This program defines a function binary_trees_ancestor
that finds the lowest common ancestor of two nodes in a binary tree (optimized version).
This program defines a function binary_tree_is_complete
that checks if a binary tree is complete.
This program defines a function binary_tree_rotate_left
that performs a left-rotation on a binary tree.
This program defines a function binary_tree_rotate_right
that performs a right-rotation on a binary tree.
This program defines a function binary_tree_is_bst
that checks if a binary tree is a binary search tree (BST).
This program defines a function array_to_bst
that builds a binary search tree (BST) from an array.
This program defines a function bst_search
that searches for a value in a binary search tree (BST).
This program defines a function bst_remove
that removes a node with a specified value from a binary search tree (BST).
This program defines a function binary_tree_is_avl
that checks if a binary tree is an AVL tree.
This program defines a function avl_insert
that inserts a value into an AVL tree.
Provide instructions on how to use the programs and any specific input requirements or expected outputs.
Contributions are welcome! If you'd like to contribute to this project, please follow these guidelines:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and test them thoroughly.
- Create a pull request with a clear description of your changes.
This project is licensed under the MIT License. See the LICENSE file for details.
Your Name