Tree Data Structures questions

Q12

GATE CS 2023 CSTree Data StructuresMCQ1 mark−1/3 if wrong
Which one of the following sequences when stored in an array at locations A[1],…,A[10]A[1], \dots, A[10] forms a max-heap?
Show answer without attempting

Answer: B

Q46

GATE CS 2023 CSTree Data StructuresMCQ2 marks−2/3 if wrong
Let AA be a priority queue for maintaining a set of elements. Suppose AA is implemented using a max-heap data structure. The operation EXTRACT-MAX(A) extracts and deletes the maximum element from AA. The operation INSERT(A, key) inserts a new element key in AA. The properties of a max-heap are preserved at the end of each of these operations.

When AA contains nn elements, which one of the following statements about the worst case running time of these two operations is TRUE?
Show answer without attempting

Answer: B

Q47

GATE CS 2023 CSTree Data StructuresMCQ2 marks−2/3 if wrong
Consider the C function 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;
}
}
When foo is called with a pointer to the root node of the given binary tree, what will it print?
Question figure
Show answer without attempting

Answer: C

0/30 correct0 marks

Related topics in Programming and Data Structures