CS and IT GATE 2017 Set-2 Questions with Answer

Ques 14 Automata


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



Ques 15 C Programming


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 )



Ques 16 C Programming


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



Ques 17 Compiler Design


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



Ques 18 Compiler Design


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)



Ques 19 Computer Network


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 Computer Network


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



Ques 21 Computer Network


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



Ques 22 Computer Network


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



Ques 23 Data Structure


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 Data Structure


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



Ques 25 Data Structure


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)



Ques 26 Data Structure


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)



Unique Visitor Count

Total Unique Visitors

Loading......