Skip to content

Beta · Data may be lost.Your data may be reset or lost.

GateBrew
← GATE CSE 2014 Set 3
Questions

Q41

MCQ2 marks, −0.67Data structuresMedium

Consider the pseudocode given below. The function DoSomething()DoSomething() takes as argument a pointer to the root of an arbitrary tree represented by the leftMostChild−rightSiblingleftMostChild-rightSibling representation. Each node of the tree is of type treeNodetreeNode.

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);
        value = value + DoSomething(tree->rightSibling);
    }
    return(value);
}

When the pointer to the root of a tree is passed as the argument to DoSomethingDoSomething, the value returned by the function corresponds to the

Sign in to save attempts.

The solution is hidden while you attempt this question. It opens once you check or show the answer.