14055. [GESP202609 六级 C++] 第 6 题

[GESP202609 六级 C++] 第 6 题

下列函数实现了二叉树的哪种遍历方式(  )。

void visit(TreeNode *root) {
    if (root == nullptr)
        return;
    visit(root->left);
    cout << root->val << " ";
    visit(root->right);
}

{{ select(1) }}

  • 前序遍历

  • 中序遍历

  • 后序遍历

  • 层序遍历