CS and IT GATE 2022 Questions with Answer

Ques 14 C Programming


What is printed by the following ANSI C program?

#include<stdio.h>
int main(int argc, char *argv[])
{
    int a[3][3][3] =
    {{1, 2, 3, 4, 5, 6, 7, 8, 9},
    {10, 11, 12, 13, 14, 15, 16, 17, 18},
    {19, 20, 21, 22, 23, 24, 25, 26, 27}};
    int i = 0, j = 0, k = 0;
    for( i = 0; i < 3; i++ ){
        for(k = 0; k < 3; k++)
            printf(“%d”, a[i][j][k]);
       printf (“\n”);
}

A

1  2  3
10 11 12
19 20 21

B

1  4   7
10 13 16
19 22 25

C

1 2 3
4 5 6
7 8 9

D

1   2   3
13 14 15
25 26 27



Ques 15 C Programming


What is printed by the following ANSI C program?

#include<stdio.h>
int main(int argc, char *argv[])
{
    int x = 1, z[2] = {10, 11};
    int *p = NULL;
    p = &x;
    *p = 10;
    p = &z[1];
    *(&z[0] + 1) += 3;
    printf("%d, %d, %d ", x, z[0], z[1]);
    return 0;
}

A

1,10,11

B

1,10,14

C

10,14,11

D

10,10,14



Ques 16 COA


Consider three floating-point numbers A, B, and C stored in registers RA, RB, and RC, respectively as per IEEE-754 single-precision floating-point format. The 32-bit content stored in these registers (in hexadecimal form) is as follows.

RA= 0xC1400000
RB = 0x42100000
RC = 0x41400000

Which one of the following is FALSE?

A

A+ C= 0

B

C= A+B

C

B = 3C

D

(B-C)> 0



Ques 17 COA


Consider a system with 2KB direct mapped data cache with a block size of 64bytes. The system has a physical address space of 64KB and a word length of 16bits. During the execution of a program, four data words P, Q, R, and S are accessed in that order 10 times (i.e., PQRSPQRS…). Hence, there are 40 accesses to data cache altogether. Assume that the data cache is initially empty and no other data words are accessed by the program. The addresses of the first bytes of P, Q, R, and S are 0xA248, 0xC28A, 0xCA8A, and 0xA262, respectively. For the execution of the above program, which of the following statements is/are TRUE with respect to the data cache?

A

Every access to S is a hit.

B

Once P is brought to the cache it is never evicted.

C

At the end of the execution only R and S reside in the cache.

D

Every access to R evicts Q from the cache.



Ques 18 COA


Let WB and WT be two set associative cache organizations that use LRU algorithm for cache block replacement. WB is a write back cache and WT is a write through cache. Which of the following statements is/are FALSE?

A

Each cache block in WB and WT has a dirty bit.

B

Every write hit in WB leads to a data transfer from cache to main memory.

C

Eviction of a block from WT will not lead to data transfer from cache to main memory.

D

A read miss in WB will never lead to eviction of a dirty block from WB.



Ques 19 COA


A processor X1 operating at 2 GHz has a standard 5-stage RISC instruction pipeline having a base CPI (cycles per instruction) of one without any pipeline hazards. For a given program P that has 30% branch instructions, control hazards incur 2 cycles stall for every branch. A new version of the processor X2 operating at same clock frequency has an additional branch predictor unit (BPU) that completely eliminates stalls for correctly predicted branches. There is neither any savings nor any additional stalls for wrong predictions. There are no structural hazards and data hazards for X1 and X2. If the BPU has a prediction accuracy of 80%, the speed up (rounded off to two decimal places) obtained by X2 over X1 in executing P is____________.


1.43 is the correct answer.


Ques 20 Compiler Design


Which one of the following statements is TRUE?

A

The LALR(1) parser for a grammar G cannot have a reduce-reduce conflict if the LR(1) parser for G does not have reduce-reduce conflict.

B

The symbol table is accessed only during the lexical analysis phase.

C

Data flow analysis is necessary for run-time memory management.

D

LR(1) parsing is sufficient for deterministic context-free languages.



Ques 21 Computer Network


Consider an enterprise network with two Ethernet segments, a web server and a firewall, connected via three routers as shown below.

What is the number of subnets inside the enterprise network?

A

3

B

12

C

6

D

8



Ques 22 Computer Network


Consider a network with three routers P, Q, R shown in the figure below. All the links have cost of unity.


The routers exchange distance vector routing information and have converged on the routing tables, after which the link Q−R fails. Assume that P and Q send out routing updates at random times, each at the same average rate. The probability of a routing loop formation (rounded off to one decimal place) between P and Q, leading to count-to-infinity problem, is___________


0.5 is the correct answer.


Ques 23 Computer Network


Consider the data transfer using TCP over a 1 Gbps link. Assuming that the maximum segment lifetime (MSL) is set to 60 seconds, the minimum number of bits required for the sequence number field of the TCP header, to prevent the sequence number space from wrapping around during the MSL is____________.


33.0 is the correct answer.


Ques 24 Computer Network


Consider a 100 Mbps link between an earth station (sender) and a satellite (receiver) at an altitude of 2100 km. The signal propagates at a speed of 3x108 m/s. The time taken (in milliseconds, rounded off to two decimal places) for the receiver to completely receive a packet of 1000 bytes transmitted by the sender is_________.


7.08 is the correct answer.


Ques 25 Computer Network


Consider the resolution of the domain name www.gate.org.in by a DNS resolver. Assume that no resource records are cached anywhere across the DNS servers and that an iterative query mechanism is used in the resolution. The number of DNS query-response pairs involved in completely resolving the domain name is________.


4 is the correct answer.


Ques 26 Data Structure


Consider the problem of reversing a singly linked list. To take an example, given the linked list below,

Which one of the following statements is TRUE about the time complexity of algorithms that solve the above problem in O(1) space?

A

The best algorithm for the problem takes θ(n) time in the worst case.

B

The best algorithm for the problem takes θ( nlog n) time in the worst case.

C

The best algorithm for the problem takes θ(n2) time in the worst case.

D

It is not possible to reverse a singly linked list in O(1) space.



Unique Visitor Count

Total Unique Visitors

Loading......