Computer Sciences > GATE 2014 SET-3 > Tree Representation
Consider the pseudocode given below. The function DoSomething() takes as argument a pointer to the root of an arbitrary tree represented by the leftMostChild-rightSibling representation. Each node of the tree is of type treeNode.
typedef struct treeNode* treeptr;
struct treeNode
{
treeptr leftMostChild, rightSibling;
};
int DoSomething (treeptr tree)
{
int value = 0;
if (tree != NULL) {
if (tree->leftMostChild == NULL)
value = 1;
else
value = DoSomething(tree->leftMostChild) + DoSomething(tree->rightSibling);
}
return (value);
}
When the pointer to the root of a tree is passed as the argument to DoSomething, the value returned by the function corresponds to the number of
typedef struct treeNode* treeptr;
struct treeNode
{
treeptr leftMostChild, rightSibling;
};
int DoSomething (treeptr tree)
{
int value = 0;
if (tree != NULL) {
if (tree->leftMostChild == NULL)
value = 1;
else
value = DoSomething(tree->leftMostChild) + DoSomething(tree->rightSibling);
}
return (value);
}
When the pointer to the root of a tree is passed as the argument to DoSomething, the value returned by the function corresponds to the number of
Correct : b
Similar Questions
A palindrome is a word that reads the same forwards and backwards. In a game
of words, a player has the following two plates painted with letters.
From...
Which number does not belong in the series below?
2, 5, 10, 17, 26, 37, 50, 64
Choose the word that is opposite in meaning to the word “coherent”.
Total Unique Visitors
Loading......