mirror of
https://github.com/hao14293/2021-Postgraduate-408.git
synced 2026-02-02 18:20:30 +08:00
Create 是否是完全二叉树.cpp
This commit is contained in:
19
DailySummary/是否是完全二叉树.cpp
Normal file
19
DailySummary/是否是完全二叉树.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
bool IsComplete(BiTree T){
|
||||
InitQueue(Q);
|
||||
if(!T) return 1;
|
||||
EnQueue(Q, T);
|
||||
while(!IsEmpty(Q)){
|
||||
DeQueue(Q, p);
|
||||
if(p){
|
||||
EnQueue(Q, p->lchild);
|
||||
EnQueue(Q, p->rchild);
|
||||
}
|
||||
else{
|
||||
while(!IsEmpty(Q)){
|
||||
DeQueue(Q, p);
|
||||
if(p) return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
Reference in New Issue
Block a user