Question 1
int maxDepth(struct node* node)
{
if (node==NULL)
return 0;
else
{
/* compute the depth of each subtree */
int lDepth = maxDepth(node->left);
int rDepth = maxDepth(node->right);
/* use the larger one */
if (lDepth > rDepth)
return X;
else return Y;
}
}
Question 2
Question 3
Question 4
int fun(struct node *root)
{
if (root == NULL)
return 0;
if (root->left == NULL && root->right == NULL)
return 0;
return 1 + fun(root->left) + fun(root->right);
}
Question 5
Question 6
Consider two binary operators '
[Tex]\uparrow[/Tex]' and '
[Tex]\downarrow[/Tex]' with the precedence of operator
[Tex]\downarrow[/Tex]being lower than that of the
[Tex]\uparrow[/Tex]operator. Operator
[Tex]\uparrow[/Tex]is right associative while operator
[Tex]\downarrow[/Tex]is left associative. Which one of the following represents the parse tree for expression (7
[Tex]\downarrow[/Tex]3
[Tex]\uparrow[/Tex]4
[Tex]\uparrow[/Tex]3
[Tex]\downarrow[/Tex]2)? (GATE CS 2011)
A
B
C
D
Question 7
Question 8
Question 9
Question 10
struct CellNode
{
struct CelINode *leftchild;
int element;
struct CelINode *rightChild;
}
int Dosomething(struct CelINode *ptr)
{
int value = 0;
if (ptr != NULL)
{
if (ptr->leftChild != NULL)
value = 1 + DoSomething(ptr->leftChild);
if (ptr->rightChild != NULL)
value = max(value, 1 + DoSomething(ptr->rightChild));
}
return (value);
}
There are 42 questions to complete.