Skip to content

Mordecai-Wambua/binary_trees

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

0x1D. C - Binary trees

Task 00:(0-binary_tree_node.c) a function that creates a binary tree node Prototype: binary_tree_t *binary_tree_node(binary_tree_t *parent, int value); Where parent is a pointer to the parent node of the node to create And value is the value to put in the new node When created, a node does not have any child Your function must return a pointer to the new node, or NULL on failure

Task 01:(1-binary_tree_insert_left.c) a function that inserts a node as the left-child of another node Prototype: binary_tree_t *binary_tree_insert_left(binary_tree_t *parent, int value); Where parent is a pointer to the node to insert the left-child in And value is the value to store in the new node Your function must return a pointer to the created node, or NULL on failure or if parent is NULL If parent already has a left-child, the new node must take its place, and the old left-child must be set as the left-child of the new node

Task 02:(2-binary_tree_insert_right.c) a function that inserts a node as the right-child of another node Prototype: binary_tree_t *binary_tree_insert_right(binary_tree_t *parent, int value); Where parent is a pointer to the node to insert the right-child in And value is the value to store in the new node Your function must return a pointer to the created node, or NULL on failure or if parent is NULL If parent already has a right-child, the new node must take its place, and the old right-child must be set as the right-child of the new node.

Task 03:(3-binary_tree_delete.c) function that deletes an entire binary tree

Prototype: void binary_tree_delete(binary_tree_t *tree); Where tree is a pointer to the root node of the tree to delete If tree is NULL, do nothing

Task 04:(4-binary_tree_is_leaf.c) a function that checks if a node is a leaf

Prototype: int binary_tree_is_leaf(const binary_tree_t *node); Where node is a pointer to the node to check Your function must return 1 if node is a leaf, otherwise 0 If node is NULL, return 0

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages