CS and IT Gate 2017 Set-2 Questions with Answer

Ques 14 Gate 2017 Set-2


Let L1 and L2 be any context-free language and R be any regular language. Then, which of the following is correct ?

I. L1 ∪ L2 is context-free.
II. L1' is context-free.
III. L1-R is context-free.
IV. L1 ∩ L2 context-free.

A

I only

B

I and III only

C

II and IV only

D

I, II and IV only


(Regular Language) is the correct answer.

Ques 15 Gate 2017 Set-2


Consider the C program fragment below which is meant to divide x by y using repeated subtractions. The variable x, y, q and r are all unsigned int.

while(r >= y)
{
    r = r - y;
    q = q + 1;
}


Which of the following conditions on the variables x, y, q and r before the execution of the fragment will ensure that the loop terminates in a state satisfying the condition x == (y*q + r)?

A

( q == r ) && ( r == 0)

B

( x <0 ) && ( r == x ) && ( y > 0 )

C

( q == 0 ) && ( r == x ) && ( y > 0 )

D

( q == 0 ) && ( y > 0 )


(C code) is the correct answer.

Ques 16 Gate 2017 Set-2


Consider the following function implemented in C:

void printxy(int x, int y)
{
    int *ptr;
    x = 0;
    ptr = &x;
    y = *ptr;
    *ptr = 1;
    printf("%d,%d", x, y);
}


The output of the printxy(1,1) is

A

0,0

B

0,1

C

1,0

D

1,1


(Functions) is the correct answer.

Ques 17 Gate 2017 Set-2


Which of the following statements about the parser is/are correct?

I. Canonical LR is more powerful than SLR.
II. SLR is more powerful than LALR.
III. SLR is more powerful than canonical LR.

A

I only

B

II only

C

III only

D

II and III only


(Parsing) is the correct answer.

Ques 18 Gate 2017 Set-2


Match the following according to input(from the left column) to the compiler phase(in the right column) that process it:

(P)Syntax Tree (i)Code generator
(Q)Character Stream (ii)Syntax analyser
(R)Intermediate representation (iii)Semantic analyser
(S)Token stream (iv)Lexical analyser

A

P -> (ii), Q -> (iii), R -> (iv), S -> (i)

B

P -> (ii), Q -> (i), R -> (iii), S -> (iv)

C

P -> (iii), Q -> (iv), R -> (i), S -> (ii)

D

P -> (i), Q -> (iv), R -> (ii), S -> (iii)


(Compiler Design) is the correct answer.

Ques 19 Gate 2017 Set-2


The maximum number of IPv4 router address addresses that can be listed in the record route (RR) option field of an IPv4 header is ____.


(a) is the correct answer.

Ques 20 Gate 2017 Set-2


Consider a socket API on Linux machine that supports UDP socket. A connected UDP socket is a UDP socket on which connect function has already been called. Which of the following statements is/are correct ?

I. A connected UDP socket can be used to communicate with multiple peers simultaneously.
II. A process can successfully call connect function again for an already connected UDP socket.

A

I only

B

II only

C

Both I and II only

D

Neither I nor II


(Computer Network) is the correct answer.

Ques 21 Gate 2017 Set-2


Consider a socket API on Linux machine that supports UDP socket. A connected UDP socket is a UDP socket on which connect function has already been called. Which of the following statements is/are correct ?

I. A connected UDP socket can be used to communicate
with multiple peers simultaneously.

II. A process can successfully call connect function
again for an already connected UDP socket.

A

I only

B

II only

C

Both I and II

D

Neither I nor II


(Computer Network) is the correct answer.

Ques 22 Gate 2017 Set-2


Consider the following statements about the routing protocols, Routing Information Protocol(RIP) and Open Shortest Path First(OSPF) in an IPv4 network.

I. RIP uses distance vector routing
II. RIP packets are sent using UDP
III. OSPF packets are sent using TCP
IV. OSPF operation is based on link-state routing
Which of the following above are CORRECT?

A

I and IV only

B

I, II and III only

C

I, II and IV only

D

II, III and IV only


(Routing protocols) is the correct answer.

Ques 23 Gate 2017 Set-2


G is undirected graph with n vertices and 25 edges such that each vertex has degree at least 3. Then the maximum possible value of n is ________


(a) is the correct answer.

Ques 24 Gate 2017 Set-2


A Circular queue has been implemented using singly linked list where each node consists of a value and a pointer to next node. We maintain exactly two pointers FRONT and REAR pointing to the front node and rear node of queue. Which of the following statements is/are correct for circular queue so that insertion and deletion operations can be performed in O(1) i.e. constant time.

I. Next pointer of front node points to the rear node.
II. Next pointer of rear node points to the front node.

A

I only

B

II only

C

Both I and II

D

Neither I nor II


(Circular Queue) is the correct answer.

Ques 25 Gate 2017 Set-2


Match the following:

(P)static char var; (i)Sequence of memory locations to store addresses
(Q)m=malloc(10);
m=NULL;
(ii)A variable in data section of memory
(R)char *ptr[10]; (iii)Request to allocate a CPU register to store data
(S)register int var1; (iv)A lost memory which cannot be freed

A

P->(ii), Q->(iv), R->(i), S->(iii)

B

P->(ii), Q->(i), R->(iv), S->(iii)

C

P->(ii), Q->(iv), R->(iii), S->(i)

D

P->(iii), Q->(iv), R->(i), S->(ii)


(Storage Class) is the correct answer.

Ques 26 Gate 2017 Set-2


Match the algorithms with their time complexities:

Algorithm Time Complexity
(P)Tower of Hanoi with n disks (i)θ(n2)
(Q)Binary Search given n sorted numbers (ii)θ(nlogn)
(R)Heap sort of n numbers at the worst case (iii)θ(2n)
(S)Addition of two n*n matrices (iv)θ(logn)

A

P-> (iii), Q -> (iv), R -> (i), S -> (ii)

B

P-> (iv), Q -> (iii), R -> (i), S -> (ii)

C

P-> (iii), Q -> (iv), R -> (ii), S -> (i)

D

P-> (iv), Q -> (iii), R -> (ii), S -> (i)


(Complexity) is the correct answer.

Unique Visitor Count

Total Unique Visitors

Loading......