Question: (20marks) QUESTION 2 Consider the code below: struct tree struct tree left: int data; struct tree right: void insert_node (struct tree **tpp, int val *tpp
(20marks) QUESTION 2 Consider the code below: struct tree struct tree left: int data; struct tree right: void insert_node (struct tree **tpp, int val *tpp (struct tree) malloc (sizeof (struct tree)) (*tpp)->data = val ; (*tpp)->left-o: *tpp)-right-0 ) else f if (val data)( insert_node (& ((*tpp)->left),val); else insert node (& *tpp)->right), val): void inorder (struct tree* tp, int* array, int *np) ( if (tp-0) (return; ) inorder (tp->left, array, array[*np] = tp->data; np): inorder (tp->right, array, np); int main0 int i,n-0; struct tree* treeptr-0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
