-
Notifications
You must be signed in to change notification settings - Fork 988
Open
Description
https://github.com/kangjianwei/Data-Structure/blob/master/Dev-C%2B%2B/CourseBook/0607_CSTree/CSTree.cpp
//提问者认为在此函数中在42-44行已经有判断树是否存在的算法,第48行和52行判断长子树和兄弟树是否存在的算法是冗余的,不知是否可以去掉?
Status ClearTree(CSTree* T) {
if(T == NULL) {
return ERROR;
}
// 在*T不为空时进行递归清理
if(*T) {
if((*T)->firstchild != NULL) {
ClearTree(&((*T)->firstchild));
}
if((*T)->nextsibling != NULL) {
ClearTree(&((*T)->nextsibling));
}
free(*T);
*T = NULL;
}
return OK;
}
Metadata
Metadata
Assignees
Labels
No labels