‹ 上一题 下一题 ›

g6-07083. 显式栈·左优先的压入 未做

1000 ms 256 MB 测试点 ? 通过率 0% 自拟题知识点题GESP-66级·深度优先搜索客观题单选

想让下面这份栈版深度优先遍历「左孩子先于右孩子被访问」,横线处应填入( )。

TreeNode* node = st.top(); st.pop();
cout << node->val << " ";
____________
  • A. if (node->left) st.push(node->left);
  • B. if (node->right) st.push(node->right);
  • C. if (node->left) st.push(node->right);
  • D. st.push(node->left); st.push(node->right);
未选择
输入
输出

            
答案