| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Clearing the tree?
is it possible?
void clear() { if (subtree !=NULL) { deletesubtree(subtree->leftlink) deletesubtree(subtree->rightlink) delete subtreeroot; subtree =NULL; } } i wanted to clear all the tree by recursion, is it possible since there is nothing in clear(?), or there is another way to clear the tree without suing recursion. |
|
#2
|
|||
|
|||
|
Code:
void clear(Tree)
{
if(Tree == NULL)
{
delete(Tree);
Tree = NULL;
}
if (Tree->left != NULL)
clear(Tree->left);
if(Tree->right != NULL)
clear(Tree->right);
}
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Clearing the tree? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|