Write a C program to Delete a Tree

To delete a tree , nike air max pas cher we need to travel all node and delete node one by one . New Balance 1400 męskie Since before deleting the parent node we should delete its children nodes first So we use preorder traversal to visit each node and delete that node . air max 1 pas cher Code :

 /* This function traverses tree in post order to to delete each and every node of the tree */ void deleteTree(struct node* node) { if (node == NULL) return; /* first delete both subtrees */ deleteTree(node-&gt;left); deleteTree(node-&gt;right); /* then delete the node */ printf(&quot;\n Deleting node: %d&quot;,  <li><a href="http://www.palermocentercity.it/adidas-yeezy-boost-350-v2.html">ADIDAS Yeezy Boost 350 V2</a></li> node-&gt;data); free(node); } 

Time & Space Complexities: Since this program is similar to traversal of tree,

Leave a Reply

Your email address will not be published. Required fields are marked *

For Inserting code :
Paste your code in the comment form, select it and then click the language link

C | C++ | Java |