📂 导航
🏫 班级管理 📚 学习中心 📝 题单 💻 编程题 🐾 宠物 💬 私信 📒 我的笔记 ⭐ 积分管理 🔐 权限管理
请先登录

📝 ### 第21题 以下代码实现的是树的()遍历。 ```cpp void dfs(TreeNode* root) { stack<TreeNode*> st; st.push(root); while (!st.empty()) { TreeNode* node = st.top(); st.pop(); cout …

📂 C++  ·  ⚡ 难度 6  ·  ❓ 单选题  ·  📖 GESP六级押题
🏷️ 六级,树遍历
📖 GESP六级押题

### 第21题

以下代码实现的是树的()遍历。
```cpp
void dfs(TreeNode* root) {
stack<TreeNode*> st;
st.push(root);
while (!st.empty()) {
TreeNode* node = st.top(); st.pop();
cout << node->val << " ";
if (node->right) st.push(node->right);
if (node->left) st.push(node->left);
}
}
```

🐛 反馈BUG