Q12
Which one of the following sequences when stored in an array at locations forms a max-heap?
Show answer without attempting
Answer: B
GATE CS · Programming and Data Structures · 3 questions
3 Tree Data Structures questions from GATE CS papers (2023), 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: B
EXTRACT-MAX(A) extracts and deletes the maximum element from . The operation INSERT(A, key) inserts a new element key in . The properties of a max-heap are preserved at the end of each of these operations.Answer: B
foo and the binary tree shown.typedef struct node {
int val;
struct node *left, *right;
} node;
int foo(node *p) {
int retval;
if (p == NULL)
return 0;
else {
retval = p->val + foo(p->left) + foo(p->right);
printf("%d ", retval);
return retval;
}
}foo is called with a pointer to the root node of the given binary tree, what will it print?
Answer: C
0/30 correct0 marks