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.
GNU General Public License v3.0
0 stars 0 forks source link

2. Insert right #3

Closed hima890 closed 3 months ago

hima890 commented 3 months ago

Write 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. alex@/tmp/binary_trees$ cat 2-main.c

include

include

include "binary_trees.h"

/**

hima890 commented 3 months ago

Ok let us see what we have here

hima890 commented 3 months ago

same as the task 0