Skip to content

Imanhamza/binary_trees

Repository files navigation

0x1D. C - Binary trees


A binary tree is a hierarchical data structure with nodes having at most two children, used for organizing and manipulating data efficiently through searching and sorting algorithms.
Creating, deleting and mapulating nodes inside the binary tree is the core of the project.


Resources


Used Data structures

Basic Binary Tree

 * struct binary_tree_s - Binary tree node
 *
 * @n: Integer stored in the node
 * @parent: Pointer to the parent node
 * @left: Pointer to the left child node
 * @right: Pointer to the right child node
 */
struct binary_tree_s
{
    int n;
    struct binary_tree_s *parent;
    struct binary_tree_s *left;
    struct binary_tree_s *right;
};

typedef struct binary_tree_s binary_tree_t;

File Structure

File Description
New node A function that creates a binary tree node.
Insert left A function that inserts a node as the left-child of another node.
Insert right A function that inserts a node as the right-child of another node.
Delete A function that deletes an entire binary tree.
Is leaf A function that checks if a node is a leaf.
Is root A function that checks if a given node is a root.
Pre-order traversal A function that goes through a binary tree using pre-order traversal.
In-order traversal A function that goes through a binary tree using in-order traversal.
Post-order traversal A function that goes through a binary tree using post-order traversal.
Height A function that measures the height of a binary tree.
Depth A function that measures the depth of a node in a binary tree.
Size A function that measures the size of a binary tree.
Leaves A function that counts the leaves in a binary tree.
Nodes A function that counts the nodes with at least 1 child in a binary tree.
Balance factor A function that measures the balance factor of a binary tree.
Is full A function that checks if a binary tree is full.
Is perfect A function that checks if a binary tree is perfect.
Sibling A function that finds the sibling of a node.
Uncle A function that finds the uncle of a node.
Lowest common ancestor A function that finds the lowest common ancestor of two nodes.
Level-order traversal A function that goes through a binary tree using level-order traversal.

General Requirements

  • All files should end with a new line.
  • The code should use the Betty style.
  • Not allowed to use global variables.
  • No more than 5 functions per file.
  • Allowed to use the standard library.
  • All prototypes of functions should be presented in The Header file.
  • For visualization purposes use this function.

About

A project deals with binary trees as a part of ALX SE program

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages