Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hima890/binary_trees

A collection of C programs for learning and implementing binary tree operations, including traversal, insertion, deletion, and validation. Ideal for understanding fundamental data structures and algorithms in C programming.
https://github.com/hima890/binary_trees

algrithm alx-africa alx-low-level-programming betty-style c-programming-language data-structures group-project

Last synced: about 10 hours ago
JSON representation

A collection of C programs for learning and implementing binary tree operations, including traversal, insertion, deletion, and validation. Ideal for understanding fundamental data structures and algorithms in C programming.

Awesome Lists containing this project

README

        

![Alt text](image.jpg)

# 0x1D C - Binary Trees :

> This project explores the concepts and implementation of binary trees in C, developed collaboratively with [Ruba Salih](https://github.com/Ruba-Salih/). It covers various operations and properties of binary trees, enhancing understanding of data structures and algorithms.

## Key Concepts Explored:

- Understanding binary trees and their structure.
- Differentiating between binary trees and Binary Search Trees (BST).
- Comparing time complexity gains compared to linked lists.
- Exploring tree properties such as depth, height, and size.
- Implementing different traversal methods for binary trees.
- Recognizing different types of binary trees: complete, full, perfect, and balanced.

## Tasks Completed :heavy_check_mark:

0. Function that creates a binary tree node.
1. Function that inserts a node as the left-child of another node.
2. Function that inserts a node as the right-child of another node.
3. Function that deletes an entire binary tree.
4. Function that checks if a node is a leaf.
5. Function that checks if a given node is a root.
6. Function that traverses a binary tree using pre-order traversal.
7. Function that traverses a binary tree using in-order traversal.
8. Function that traverses a binary tree using post-order traversal.
9. Function that measures the height of a binary tree.
10. Function that measures the depth of a node in a binary tree.
11. Function that measures the size of a binary tree.
12. Function that counts the leaves in a binary tree.
13. Function that counts the nodes with at least 1 child in a binary tree.
14. Function that measures the balance factor of a binary tree.
15. Function that checks if a binary tree is full.
16. Function that checks if a binary tree is perfect.
17. Function that finds the sibling of a node.
18. Function that finds the uncle of a node.
19. Function that finds the lowest common ancestor of two nodes.
20. Function that traverses a binary tree using level-order traversal.
21. Function that checks if a binary tree is complete.
22. Function that performs a left-rotation on a binary tree.
23. Function that performs a right-rotation on a binary tree.
24. Function that checks if a binary tree is a valid Binary Search Tree (BST).
25. Function that inserts a value in a Binary Search Tree (BST).
26. Function that builds a Binary Search Tree (BST) from an array.
27. Function that searches for a value in a Binary Search Tree (BST).
28. Function that removes a node from a Binary Search Tree (BST).
29. Average time complexities of operations on a Binary Search Tree (BST).
30. Function that checks if a binary tree is a valid AVL Tree (In progress).
31. Function that inserts a value in an AVL Tree (In progress).
32. Function that builds an AVL Tree from an array (In progress).
33. Function that removes a node from an AVL Tree (In progress).
34. Function that builds an AVL Tree from a sorted array (In progress).
35. Average time complexities of operations on an AVL Tree (In progress).
36. Function that checks if a binary tree is a valid Max Binary Heap (In progress).
37. Function that inserts a value in a Max Binary Heap (In progress).
38. Function that builds a Max Binary Heap from an array (In progress).
39. Function that extracts the root node of a Max Binary Heap (In progress).
40. Function that converts a Binary Max Heap to a sorted array (In progress).
41. Average time complexities of operations on a Binary Heap (In progress).

## Results :chart_with_upwards_trend:

### Implemented Files:

- [0-binary_tree_node.c](https://github.com/hima890/binary_trees/blob/main/0-binary_tree_node.c)
- [1-binary_tree_insert_left.c](https://github.com/hima890/binary_trees/blob/main/1-binary_tree_insert_left.c)
- [2-binary_tree_insert_right.c](https://github.com/hima890/binary_trees/blob/main/2-binary_tree_insert_right.c)
- [3-binary_tree_delete.c](https://github.com/hima890/binary_trees/blob/main/3-binary_tree_delete.c)
- [4-binary_tree_is_leaf.c](https://github.com/hima890/binary_trees/blob/main/4-binary_tree_is_leaf.c)
- [5-binary_tree_is_root.c](https://github.com/hima890/binary_trees/blob/main/5-binary_tree_is_root.c)
- [6-binary_tree_preorder.c](https://github.com/hima890/binary_trees/blob/main/6-binary_tree_preorder.c)
- [7-binary_tree_inorder.c](https://github.com/hima890/binary_trees/blob/main/7-binary_tree_inorder.c)
- [8-binary_tree_postorder.c](https://github.com/hima890/binary_trees/blob/main/8-binary_tree_postorder.c)
- [9-binary_tree_height.c](https://github.com/hima890/binary_trees/blob/main/9-binary_tree_height.c)
- [10-binary_tree_depth.c](https://github.com/hima890/binary_trees/blob/main/10-binary_tree_depth.c)
- [11-binary_tree_size.c](https://github.com/hima890/binary_trees/blob/main/11-binary_tree_size.c)
- [12-binary_tree_leaves.c](https://github.com/hima890/binary_trees/blob/main/12-binary_tree_leaves.c)
- [13-binary_tree_nodes.c](https://github.com/hima890/binary_trees/blob/main/13-binary_tree_nodes.c)
- [14-binary_tree_balance.c](https://github.com/hima890/binary_trees/blob/main/14-binary_tree_balance.c)
- [15-binary_tree_is_full.c](https://github.com/hima890/binary_trees/blob/main/15-binary_tree_is_full.c)
- [16-binary_tree_is_perfect.c](https://github.com/hima890/binary_trees/blob/main/16-binary_tree_is_perfect.c)
- [17-binary_tree_sibling.c](https://github.com/hima890/binary_trees/blob/main/17-binary_tree_sibling.c)
- [18-binary_tree_uncle.c](https://github.com/hima890/binary_trees/blob/main/18-binary_tree_uncle.c)
- [100-binary_trees_ancestor.c](https://github.com/hima890/binary_trees/blob/main/100-binary_trees_ancestor.c)
- [101-binary_tree_levelorder.c](https://github.com/hima890/binary_trees/blob/main/101-binary_tree_levelorder.c)
- [102-binary_tree_is_complete.c](https://github.com/hima890/binary_trees/blob/main/102-binary_tree_is_complete.c)
- [103-binary_tree_rotate_left.c](https://github.com/hima890/binary_trees/blob/main/103-binary_tree_rotate_left.c)
- [104-binary_tree_rotate_right.c](https://github.com/hima890/binary_trees/blob/main/104-binary_tree_rotate_right.c)
- [110-binary_tree_is_bst.c](https://github.com/hima890/binary_trees/blob/main/110-binary_tree_is_bst.c)
- [111-bst_insert.c](https://github.com/hima890/binary_trees/blob/main/111-bst_insert.c)
- [112-array_to_bst.c](https://github.com/hima890/binary_trees/blob/main/112-array_to_bst.c)
- [113-bst_search.c](https://github.com/hima890/binary_trees/blob/main/113-bst_search.c)
- [114-bst_remove.c](https://github.com/hima890/binary_trees/blob/main/114-bst_remove.c)
- [115-O](https://github.com/hima890/binary_trees/blob/main/115-O)
- [120-binary_tree_is_avl.c](https://github.com/hima890/binary_trees/blob/main/120-binary_tree_is_avl.c)

### Additional Information :construction:
# Project Structre
.
├── 0-binary_tree_node.c
├── 100-binary_trees_ancestor.c
├── 101-binary_tree_levelorder.c
├── 101-main.c
├── 102-binary_tree_is_complete.c
├── 103-binary_tree_rotate_left.c
├── 104-binary_tree_rotate_right.c
├── 10-binary_tree_depth.c
├── 110-binary_tree_is_bst.c
├── 111-bst_insert.c
├── 112-array_to_bst.c
├── 113-bst_search.c
├── 114-bst_remove.c
├── 115-O
├── 11-binary_tree_size.c
├── 120-binary_tree_is_avl.c
├── 120-is_avl
├── 120-main.c
├── 121-avl_insert.c
├── 122-array_to_avl.c
├── 123-avl_remove.c
├── 124-sorted_array_to_avl.c
├── 12-binary_tree_leaves.c
├── 130-binary_tree_is_heap.c
├── 13-binary_tree_nodes.c
├── 14-binary_tree_balance.c
├── 15-binary_tree_is_full.c
├── 16-binary_tree_is_perfect.c
├── 17-binary_tree_sibling.c
├── 18-binary_tree_uncle.c
├── 1-binary_tree_insert_left.c
├── 2-binary_tree_insert_right.c
├── 3-binary_tree_delete.c
├── 4-binary_tree_is_leaf.c
├── 5-binary_tree_is_root.c
├── 6-binary_tree_preorder.c
├── 7-binary_tree_inorder.c
├── 8-binary_tree_postorder.c
├── 9-binary_tree_height.c
├── AUTHORS
├── binary_tree_print.c
├── binary_trees.h
├── LICENSE
├── Notes
│ ├── c.txt
│ └── github.txt
├── output
│ └── binary_trees
└── README.md
#### Note:
Functions files cant run without the main test case file