/**
 * struct TreeNode {
 *	int val;
 *	struct TreeNode *left;
 *	struct TreeNode *right;
 * };
 */
/**
 * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
 *
 * 
 * @param root TreeNode类 
 * @return bool布尔型
 */
bool isCompleteTree(struct TreeNode* root ) {
    // write code here
    if(root == NULL) return true;
    struct TreeNode** queue = (struct TreeNode**)malloc(sizeof(struct TreeNode*) * 100);
    int qIdx = -1;
    int hIdx = -1;
    queue[++qIdx] = root;
    bool empty = false;
    while(qIdx != hIdx) {
        struct TreeNode* c = queue[++hIdx];
        if(c != NULL) queue[++qIdx] = c->left;
        if(c != NULL) queue[++qIdx] = c->right;
        if(c == NULL) empty = true;
        if(empty == true && c != NULL) {
            free(queue);
            return false;
        }
    }
    free(queue);
    return true;
}