3434 . 单选题 Puls

上⼀题的⼆叉树深度计算还可以采⽤⼆叉树的⼴度优先搜索来实现。以下基于⼆叉树的⼴度优先搜索实现的深度计算函数中横线上应填写?

上一题见: https://www.hixinao.com/tiku/cpp/show-3433.html

#include <queue>

int max_depth_bfs(tree_node * root) {
    if (root == nullptr) {
        return 0; // 如果树为空,深度为 0
    }
    queue < tree_node * > q;
    q.push(root);
    int depth = 0;
    // 使用队列进行层序遍历
    while (!q.empty()) {
        ———————————————————————— // 在此处填入代码
        for (int i = 0; i < level_size; ++i) {
            tree_node * node = q.front();
            q.pop();
            if (node -> left) {
                q.push(node -> left);
            }
            if (node -> right) {
                q.push(node -> right);
            }
        }
    }
    return depth;
}