Q22
Consider a complete binary tree where the left and the right subtrees of the root are max-heaps. The lower bound for the number of operations to convert the tree to a heap is
Show answer without attempting
Answer: A
GATE CS · Programming and Data Structures · 52 questions
52 Tree Data Structures questions from GATE CS papers, each with the official answer key. Part of Programming and Data Structures. Answer any question right here and it is marked straight away, or practise them one at a time.
Answer: A
Answer: 19
Answer: A

Answer: 6

Answer: A
Answer: 110
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);
}Answer: D
Answer: 1
Answer: C
Answer: D
Answer: C
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
}
}
}Answer: A
0/120 correct0 marks