Question: //Minimalistic implementation of a binary tree (BT). //Each node is storing an integer key. //Insertion of new nodes into the BT is done manually Hinclude

//Minimalistic implementation of a binary tree (BT). //Each node is storing an integer key. //Insertion of new nodes into the BT is done manually Hinclude stdio.h> Hinclude stdlib.h> typedef struct Node\{ int key; struct Node * Left; struct Node * p Right; JNode; Node pR Root = NULL; //access point(er) to the BT Node createNode(int val)\{ Node p = malloc(sizeof(Node)); p->key = val; p> pLeft = NULL; p> pRight = NULL; 3 void print Tree(Node p)f if (p) //equivalent to if ( p !=NULI) // printing the key in between the L and R children print Tree(p->pleft); printf("\%i ", p->key); print Tree(p->pRight); 3 1 int mainfvoid) int m; Node "pNode; //creating the root m=9; pNode = createNode (m); pRoot = pNode; // now insert the nodes w/keys 5, 12, 7 //Your code here! printTree(pRoot); a) Starting from the code insert the remaining nodes 1,4 , and 10 , from the figure: b) Continuing the code from \#3 in the practice section, modify the function searchTree to als print the keys in all the nodes traversed in the search process Test with the existing keys 5, 12, and 7, and also with 10,0, and 20. c) Continuing the code from \#6 above, write a new function searchTreeDepth to return the depth at which the key was found. - The root has depth zero. - If the key is not found, the function should return -1. Test with the existing keys 5, 12, and 7 , and also with 10,0, and 20. - Hint: Use a third function argument depth to keep track of the depth. What value should we give this argument when we call the function in main
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
