MCQ2 marks
The pre-order traversal of a binary search tree is given by 12, 8, 6, 2, 7, 9, 10, 16, 15, 19, 17, 20. Then the post-order traversal of this tree is:
Single correct
Answer key coming soon
GATE CSE previous year questions · Programming & Data Structures
Single correct
Answer key coming soon
Numerical answer
Answer key coming soon
Single correct
Answer key coming soon
Numerical answer
Answer key coming soon
Single correct
Single correct
Single correct
Numerical answer
Numerical answer
Single correct
Numerical answer

Numerical answer

Single correct
Numerical answer
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);
value = value + 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 theSingle correct
Single correct
Answer key coming soon
Single correct
Answer key coming soon
Single correct
Answer key coming soon
height(root) to compute the height of a binary tree rooted at the tree pointer root.
int height (treeptr n)
{ if (n == NULL) return -1;
if (n -> left == NULL)
if (n -> right == NULL) return 0;
else return [B1] ; // Box 1
else { h1 = height (n -> left);
if (n -> right == NULL) return (1+h1);
else { h2 = height (n -> right);
return [B2] ; // Box 2
}
}
}
The appropriate expressions for the two boxes B1 and B2 areSingle correct
Answer key coming soon
Single correct
Answer key coming soon