Question: WRITE IN C: /* Exercise 4.e.iv (14 Points) Use the given template to complete a C program implementation of a Binary Tree Add comments where

WRITE IN C:WRITE IN C: /* Exercise 4.e.iv (14 Points) Use the given template

to complete a C program implementation of a Binary Tree Add comments

/* Exercise 4.e.iv (14 Points) Use the given template to complete a C program implementation of a Binary Tree Add comments where necessary, explaining each significant functionality typedef struct Node { void* data; struct Node* left; struct Node* right; } Node; typedef struct BinaryTree { Node* top; int size: chart type; int (*compare) (void*, void*) ip; void (*print) (void) vp; } BinaryTree; BinaryTree* bintree_initialize (int i, chart c, int (*) (voida, void*) ip, void (*) (void) vp) { //TODO (1 point) Input Specifications An integer representing a type size, a char pointer representing a type name, a function pointer to a int(void*,void*) comparison function, and a function pointer to a void(void *) print function Expected Return value A pointer to an initialized Binary Tree Extra Requirements This function should create and store a binary tree with the appropriate fields and a NULL root node } Node* create_node (int i, void+ v) { //TODO (1 point) Input Specifications An integer representing a data size and a void pointer to an element. Expected Return value A Node with null child pointers and the data set to match the element. Extra Requirements IN/A } bool insert (BinaryTreet b, void+ v) { //TODO (1 point) Input Specifications A pointer to a BinaryTree and a void pointer representing an element. Expected Return value True if the element was inserted successfully. Otherwise false. Extra Requirements IN/A } bool search (BinaryTreet b, void+ v) { //TODO (1 point) Input Specifications A pointer to a BinaryTree and a void pointer representing an element Expected Return value True if the element exists in the binary tree. Otherwise false. Extra Requirements IN/A } void print_in_order (BinaryTree* b) { //TODO (1 point) Input Specifications A pointer to a BinaryTree. Expected Return value N/A Extra Requirements Print the binary tree following the in-order traversal requirements. } void print_pre_order (BinaryTree* b) { //TODO (1 point) Input Specifications A pointer to a BinaryTree. Expected Return value N/A Extra Requirements Print the binary tree following the pre-order traversal requirements } void print_post_order (BinaryTree* b) { //TODO (1 point) Input Specifications A pointer to a Binary Tree. Expected Return value N/A Extra Requirements Print the binary tree following the post-order traversal requirements. } void print_reverse_order (BinaryTree* b) { //TODO (1 point) Input Specifications A pointer to a Binary Tree. Expected Return value N/A Extra Requirements Print the binary tree following the reverse-order traversal requirements. } bool insert_recursive (BinaryTree* b, Node* n, void+ v) { //TODO (1 point) Input Specifications A pointer to a BinaryTree, a pointer to a Node, and a void pointer representing an element. Expected Return value True if the function successfully inserted the element to the tree. Otherwise false Extra Requirements This function should be called by the insert function to aid in the recursive traversal process. This function will do the majority of the inserting } bool search_recursive (BinaryTreet b, Node* n, void+ v) { //TODO (1 point) Input Specifications A pointer to a BinaryTree, a pointer to a Node, and a void pointer representing an element. Expected Return Value True if the function successfully finds the element in the tree. Otherwise false. Extra Requirements This function should be called by the search function to aid in the recursive traversal process. This function will do the majority of the searching. } void in_order_recursive (BinaryTree* b, Node* n) { //TODO (1 point) Input Specifications A pointer to a Binary Tree and a pointer to a Node. Expected Return value N/A This function should be called by the print in order function to aid in the recursive traversal process. ) Extra Requirements This function will do the majority of the traversal and will print the values accordingly void pre_order_recursive (BinaryTree* b, Node* n) { //TODO (1 point) Input Specifications A pointer to a BinaryTree and a pointer to a Node. Expected Return value N/A This function should be called by the print pre order function to aid in the recursive traversal process. ) Extra Requirements This function will do the majority of the traversal and will print the values accordingly void post_order_recursive (BinaryTree* b, Node* n) { //TODO (1 point) Input Specifications A pointer to a BinaryTree and a pointer to a Node. Expected Return value N/A This function should be called by the print post order function to aid in the recursive traversal process. ) Extra Requirements This function will do the majority of the traversal and will print the values accordingly. void reverse_order_recursive (BinaryTree* b, Node* n) { //TODO (1 point) Input Specifications A pointer to a BinaryTree and a pointer to a Node. Expected Return value N/A This function should be called by the print reverse order function to aid in the recursive traversal process. Extra Requirements } This function will do the majority of the traversal and will print the values accordingly

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!