Answered step by step
Verified Expert Solution
Question
1 Approved Answer
5. (10pt) Binary Search Tree (BST)1 You are asked to implement the following function: void copyBSTintoArray (nodeT t, int array])which copies the values Irom a
5. (10pt) Binary Search Tree (BST)1 You are asked to implement the following function: void copyBSTintoArray (nodeT t, int array])which copies the values Irom a given BST into an array such that the values in the array will be sorted For example, after passing any of the following BSTs into your function, the array should have (3, 5, 6, 7,9) t1 t2 typedef struct node 6 5 int key: struct node left, right , nodeT, treeT; 7 7 int index=0; 5 9 6 9 Before calling your function, assume that we count the number of values in the BST and accordingly allocate enough memory for the array. So you can safely assume that the array in your function has enough space to store all the values in the given BST. Also as a hint, we defined a global variable index and set it to zero before calling your function. void CopyBSTintoArray (nodeT *t, int arrayt)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started