Join Telegram Channel for DXC exam Discussion & help!

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.

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

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.