Question: Task 4 : Destroy the Tree: destroy During add _ node ( ) we malloc ( ) ' ed a lot, so before exiting our
Task : Destroy the Tree: destroy
During addnode we malloced a lot, so before exiting our program we need to free those spaces on
the heap by calling destroy :
void destroytreet;
where treet argument is the pointer to the tree. One thing to pay attention to is how many malloc we
used in addnode then we should free same amount of time. Also, for each node, what's the order of
multiple frees
Again, it'll be easier to do that in recursion. You are free to create helper functions.
Note
We will emphasize this again: because this is a generic BST you must not use ifelse to discriminate different
data types in your code. For example, the following is not allowed:
if sizeof data
Please write in C
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
