Beispiel #1
0
void DestoryTree( Tree P )
{
	if( !IsEmpty(P) )
	{
		if( !IsEmpty(P->Left) )DestoryTree( P->Left );
		if( !IsEmpty(P->Rigth) )DestoryTree( P->Rigth );
		free(P);
	}
}
void DestoryTree(BinaryTree *root){
	if(root == NULL) 	return ;
	if(!root->lNode)	DestoryTree(root->lNode);
	if(!root->rNode)	DestoryTree(root->rNode);
	if(root->lNode == NULL && root->rNode == NULL){
		free(root);
		root = NULL;
	}
}
Beispiel #3
0
int main(int argc, const char *argv[]) {

	Node* root = NULL;
	const char* pPreOrder = "abdcef";
	const char* pInOrder = "bdaecf";
	Rebuild2(pPreOrder, pInOrder, (int)strlen(pPreOrder), &root);
	
	PrintNodeAllLevel(root);
	printf("\n");

	DestoryTree(root);
	return 0;
}
int main(int argc, char **argv)
{
	int a[] = {8,11,6,7,19,9,22,20};
	int n = sizeof(a)/sizeof(int);
	BinaryTree *root = NULL;
 	CreateTree(&root, a, n);
	ShowTree(root);

 	int del = 20;
	DeleteTree(root,del);
	printf("\n:::\n");
 	ShowTree(root);
	DestoryTree(root);
 	return 0;
}
SuffixTrie::~SuffixTrie() {  
  if(NULL != pRoot) {
    DestoryTree();  
  }
  pRoot = NULL;  
}  
Beispiel #6
0
/**
* @brief Destory tree.
*
* @param root tree root.
*/
void DestoryTree(Node* root) {
	if (NULL == root) return;
	DestoryTree(root->lChild);
	DestoryTree(root->rChild);
	free(root);
}