以下代码实现二叉树左子树优先的深度优先搜索算法,则横线上应填写( )。
void dfs(TreeNode *root) {
if (root == nullptr)
return;
stack<TreeNode *> s;
s.push(root);
while (!s.empty()) {
TreeNode *node = s.top();
s.pop();
cout << node->value << " ";
———————————————————————— // 在此处填入代码
}
}
正在加载题目数据…
子题
该题型需在试卷/作业中作答,单题练习暂不支持
答案解析