单选题 适中
#21383

阅读以下广度优先搜索的代码: void bfs ( TreeNode * root ) { if ( root == NULL ) { return ; } q…

阅读以下广度优先搜索的代码:

void bfs(TreeNode* root) {
	if (root == NULL) {
		return;
	}
	queue<TreeNode*> q;
	q.push(root);
	while (!q.empty()) {
		TreeNode* current = q.front();
		q.pop();
		cout << current->val << " ";
		if (current->left) {
			q.push(current->left);
		}
		if (current->right) {
			q.push(current->right);
		}
	}
}

使用以上算法遍历以下这棵树,可能的输出是(   )。

未登录也能判分,登录后才会记录
答案与解析
正确答案:C
这道题暂未补解析。