Question: Write C programs tree.h, tree.c and a7q1.c to create, operate and test binary a tree data structure. tree.h and tree.c contain the following data type
Write C programs tree.h, tree.c and a7q1.c to create, operate and test binary a tree data structure.
tree.h and tree.c contain the following data type definition, function prototypes and implementations.
- design and implement a general binary tree data structure with the following features.
typedef struct tree_node { int data; struct tree_node *left; struct tree_node *right; } TNODE; /* creates a TNODE node and sets the data to value and returns the pointer */ TNODE *new_node(int value); /* this computes and returns the number of node count of the tree passed by root.*/ int get_count(TNODE *root); /* this computes and returns the number of the tree passed by root. */ int get_height(TNODE *root); /* this cleans the tree passed by rootp. */ void clean_tree(TNODE **rootp); /* this displays the node data of the tree by pre-order. */ void display_preorder(TNODE *root); /* this displays the node data of the tree by in-order. */ void display_inorder(TNODE *root); /* this displays the node data of the tree by post-order. */ void display_postorder(TNODE *root); /* this displays the tree in 2D text format */ void display_tree(TNODE *root, int prelen); /* this displays the tree in breadth-first order using additional queue data structure */ void iterative_bf_display(TNODE *root); /* this does the breadth-first search */ TNODE *iterative_bf_search(TNODE *root, int val); /* this does the depth-first search */ TNODE *iterative_df_search(TNODE *root, int val);
I just need help implementing the code above
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
