Consider a binary tree implementation. The root address is stored in variable root. Given the address of a node is variable node, its value, right and root could node address can be accessed using the following statements respectively node-> value ,node -> right, node-> left. Srikanth writes the following function to do a preorder traversal of the tree.
function preordertraverse(n0de)
{
print node -> value
if(Conditon X)
{
preordertraverse(node ->left)
}
if(Condition Y)
{
preordertraverse(node ->right)
}
return
}
What is the Condition X and Condition Y ?
A. Condition X: node -> left is not equal null
B. Condition X: node -> right is not equal null,Condition Y:node -> right is not equal null,Condition
Y:node -> left is not equal null
C. Condition X: node -> left is equal null
D. Condition X: node -> right is equal null, Condition Y:node -> right is equal null, Condition Y:node -
> left is equal null.
Answer: Option A