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 · 7 questions
7 Programming and Data Structures questions from GATE CS papers (2023), each with the official answer key. Answer any question right here and it is marked straight away, or practise them one at a time.
Answer: B
SLLdel be a function that deletes a node in a singly-linked list given a pointer to the node and a pointer to the head of the list. Similarly, let DLLdel be another function that deletes a node in a doubly-linked list given a pointer to the node and a pointer to the head of the list.SLLdel and DLLdel?Answer: D
#include<stdio.h>
int funcp(){
static int x = 1;
x++;
return x;
}
int main(){
int x,y;
x = funcp();
y = funcp()+x;
printf("%d\n", (x+y));
return 0;
}Answer: 7
int main()
{
f1();
f2(2);
f3();
return(0);
}
int f1()
{
return(1);
}
int f2(int X)
{
f3();
if (X==1)
return f1();
else
return (X*f2(X-1));
}
int f3()
{
return(5);
}Answer: A
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
push the elements of from to in that order into .enqueue the elements of from to in that order into .pop an element from .dequeue an element from .pop an element from .dequeue an element from .dequeue an element from and push the same element into .pop an element from .pop an element from .top element of after executing the above operations is ____________.Answer: 8
0/70 correct0 marks