S
sugaray
1
/ \
2 3
/ / \
4 5 6
\ / \
7 8 9
Given the binary trees above, determine the order in which the
nodes will be visited in the mixed order given by invoking
function A:
typedef struct treenode TreeNode;
typedef struct treenode {
TreeNode *left;
int entry;
TreeNode *right;
}TreeNode;
void A(TreeNode *root)
{
if(root) {
printf("%d\n",root->entry);
B(root->left,Visit);
B(root->right,Visit);
}
}
void B(TreeNode *root)
{
if(root) {
A(root->left,Visit);
printf("%d\n",root->entry);
A(root->right,Visit);
}
}
/ \
2 3
/ / \
4 5 6
\ / \
7 8 9
Given the binary trees above, determine the order in which the
nodes will be visited in the mixed order given by invoking
function A:
typedef struct treenode TreeNode;
typedef struct treenode {
TreeNode *left;
int entry;
TreeNode *right;
}TreeNode;
void A(TreeNode *root)
{
if(root) {
printf("%d\n",root->entry);
B(root->left,Visit);
B(root->right,Visit);
}
}
void B(TreeNode *root)
{
if(root) {
A(root->left,Visit);
printf("%d\n",root->entry);
A(root->right,Visit);
}
}