Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/cgrade/binary_trees

This Repo Contains the ALX SWE Tasks on Data Structure and Algorithm on The Binary Tree and Binary Search , All was done in the C Programming language
https://github.com/cgrade/binary_trees

Last synced: 12 days ago
JSON representation

This Repo Contains the ALX SWE Tasks on Data Structure and Algorithm on The Binary Tree and Binary Search , All was done in the C Programming language

Awesome Lists containing this project

README

        

# 0x1D C - Binary trees :pencil2:

At the end of this project, I was able to undesrtand these questions:

* What is a binary tree
* What is the difference between a binary tree and a Binary Search Tree
* What is the possible gain in terms of time complexity compared to linked lists
* What are the depth, the height, the size of a binary tree
* What are the different traversal methods to go through a binary tree
* What is a complete, a full, a perfect, a balanced binary tree

## Tasks :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 goes through a binary tree using pre-order traversal
7. Function that goes through a binary tree using in-order traversal
8. Function that goes through 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 goes through 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
25. Function that inserts a value in a Binary Search Tree
26. Function that builds a Binary Search Tree from an array
27. Function that searches for a value in a Binary Search Tree
28. Function that removes a node from a Binary Search Tree
29. What are the average time complexities of those operations on a Binary Search Tree
30. Function that checks if a binary tree is a valid AVL Tree
31. Function that inserts a value in an AVL Tree
32. Function that builds an AVL tree from an array
33. Function that removes a node from an AVL tree
34. Function that builds an AVL tree from an array
35. What are the average time complexities of those operations on an AVL Tree
36. Function that checks if a binary tree is a valid Max Binary Heap (Task in progress)
37. Function that inserts a value in Max Binary Heap (Task in progress)
38. Function that builds a Max Binary Heap tree from an array (Task in progress)
39. Function that extracts the root node of a Max Binary Heap (Task in progress)
40. Function that converts a Binary Max Heap to a sorted array of integers (Task in progress)
41. What are the average time complexities of those operations on a Binary Heap

## Results :chart_with_upwards_trend:

| Filename |
| ------ |
| [0-binary_tree_node.c](https://github.com/cgrade/binary_trees/blob/master/0-binary_tree_node.c)|
| [1-binary_tree_insert_left.c](https://github.com/cgrade/binary_trees/blob/master/1-binary_tree_insert_left.c)|
| [2-binary_tree_insert_right.c](https://github.com/cgrade/binary_trees/blob/master/2-binary_tree_insert_right.c)|
| [3-binary_tree_delete.c](https://github.com/cgrade/binary_trees/blob/master/3-binary_tree_delete.c)|
| [4-binary_tree_is_leaf.c](https://github.com/cgrade/binary_trees/blob/master/4-binary_tree_is_leaf.c)|
| [5-binary_tree_is_root.c](https://github.com/cgrade/binary_trees/blob/master/5-binary_tree_is_root.c)|
| [6-binary_tree_preorder.c](https://github.com/cgrade/binary_trees/blob/master/6-binary_tree_preorder.c)|
| [7-binary_tree_inorder.c](https://github.com/cgrade/binary_trees/blob/master/7-binary_tree_inorder.c)|
| [8-binary_tree_postorder.c](https://github.com/cgrade/binary_trees/blob/master/8-binary_tree_postorder.c)|
| [9-binary_tree_height.c](https://github.com/cgrade/binary_trees/blob/master/9-binary_tree_height.c)|
| [10-binary_tree_depth.c](https://github.com/cgrade/binary_trees/blob/master/10-binary_tree_depth.c)|
| [11-binary_tree_size.c](https://github.com/cgrade/binary_trees/blob/master/11-binary_tree_size.c)|
| [12-binary_tree_leaves.c](https://github.com/cgrade/binary_trees/blob/master/12-binary_tree_leaves.c)|
| [13-binary_tree_nodes.c](https://github.com/cgrade/binary_trees/blob/master/13-binary_tree_nodes.c)|
| [14-binary_tree_balance.c](https://github.com/cgrade/binary_trees/blob/master/14-binary_tree_balance.c)|
| [15-binary_tree_is_full.c](https://github.com/cgrade/binary_trees/blob/master/15-binary_tree_is_full.c)|
| [16-binary_tree_is_perfect.c](https://github.com/cgrade/binary_trees/blob/master/16-binary_tree_is_perfect.c)|
| [17-binary_tree_sibling.c](https://github.com/cgrade/binary_trees/blob/master/17-binary_tree_sibling.c)|
| [18-binary_tree_uncle.c](https://github.com/cgrade/binary_trees/blob/master/18-binary_tree_uncle.c)|
| [100-binary_trees_ancestor.c](https://github.com/cgrade/binary_trees/blob/master/100-binary_trees_ancestor.c)|
| [101-binary_tree_levelorder.c](https://github.com/cgrade/binary_trees/blob/master/101-binary_tree_levelorder.c)|
| [102-binary_tree_is_complete.c](https://github.com/cgrade/binary_trees/blob/master/102-binary_tree_is_complete.c)|
| [103-binary_tree_rotate_left.c](https://github.com/cgrade/binary_trees/blob/master/103-binary_tree_rotate_left.c)|
| [104-binary_tree_rotate_right.c](https://github.com/cgrade/binary_trees/blob/master/104-binary_tree_rotate_right.c)|
| [110-binary_tree_is_bst.c](https://github.com/cgrade/binary-trees/blob/master/110-binary_tree_is_bst.c)|
| [111-bst_insert.c](https://github.com/cgrade/binary_trees/blob/master/111-bst_insert.c)|
| [112-array_to_bst.c](https://github.com/cgrade/binary_trees/blob/master/112-array_to_bst.c)|
| [113-bst_search.c](https://github.com/cgrade/binary_trees/blob/master/113-bst_search.c)|
| [114-bst_remove.c](https://github.com/cgrade/binary_trees/blob/master/114-bst_remove.c)|
| [115-O](https://github.com/cgrade/binary_trees/blob/master/115-O)|
| [120-binary_tree_is_avl.c](https://github.com/cgrade/binary_trees/blob/master/120-binary_tree_is_avl.c)|
| [121-avl_insert.c](https://github.com/cgrade/binary_trees/blob/master/121-avl_insert.c)|
| [122-array_to_avl.c](https://github.com/cgrade/binary_trees/blob/master/122-array_to_avl.c)|
| [123-avl_remove.c](https://github.com/cgrade/binary_trees/blob/master/123-avl_remove.c)|
| [124-sorted_array_to_avl.c](https://github.com/cgrade/binary_trees/blob/master/124-sorted_array_to_avl.c)|
| [125-O](https://github.com/cgrade/binary_trees/blob/master/125-O)|
| [130-binary_tree_is_heap.c](https://github.com/cgrade/binary_trees/blob/master/130-binary_tree_is_heap.c)|
| 131-heap_insert.c - Task pending|
| 132-array_to_heap.c - Task pending|
| 133-heap_extract.c - Task pending|
| 134-heap_to_sorted_array.c - Task pending|
| [135-O](https://github.com/cgrade/binary_trees/blob/master/135-O)|

## Additional info :construction:
### Resources

- GLIBC 2.24
- gcc 4.8.4
- betty linter 0.32
- Valgrind

### Try It On Your Machine :computer:

SORRY, DESPITE THE PROJECT IS FUNCTIONAL FOR EDUCATIONAL PURPOSES FOR YOU TO LEARN I AM NOT LEAVING IT AVAILABLE FOR TEST