题目
单项选择题
TTrave_Alg_3 Which one of the pseudocode given below is written for post-order traversal of a Binary Search Tree?
选项
A.BSTPrintInorder(node)
{
if (node is null)
return
BSTPrintInorder(node->left)
BSTPrintInorder(node->right)
}
B.BSTPrintInorder(node)
{
if (node is null)
return
BSTPrintInorder(node->left)
BSTPrintInorder(node->right)
Print node
}
C.BSTPrintInorder(node)
{
if (node is null)
return
Print node
BSTPrintInorder(node->left)
BSTPrintInorder(node->right)
}
D.BSTPrintInorder(node)
{
if (node is null)
return
BSTPrintInorder(node->left)
Print node
BSTPrintInorder(node->right)
}
查看解析
标准答案
Please login to view
思路分析
Let’s break down what post-order traversal means and then evaluate each option step by step.
- Post-order traversal of a binary tree visits the left subtree first, then the right subtree, and finally processes the current node (prints its value). This order is L → R → Node.
Option 1:
- The pseudocode shows: traverse left, then traverse right, then Print node. This exactly matches the L → R → Node sequence required for pos......Login to view full explanation登录即可查看完整答案
我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。
类似问题
TTrave_2 Consider the post-order traversal of the following BST. Note that visiting the node is actually printing the node. Which node is printed 5th?
How does In-Order traversal work in a Binary Tree?
Which tree traversal method visits the nodes level by level starting from the root?
Visiting the left subtree, then the node, then the right subtree is called:
更多留学生实用工具
希望你的学习变得更简单
加入我们,立即解锁 海量真题 与 独家解析,让复习快人一步!