Subjects in this paper

GATE CS 2017 CS-1 questions

Q1

Discrete MathematicsMCQ1 mark−1/3 if wrong
The statement (¬p)⇒(¬q)(\neg p) \Rightarrow (\neg q) is logically equivalent to which of the statements below?

I. p⇒qp \Rightarrow q
II. q⇒pq \Rightarrow p
III. (¬q)∨p(\neg q) \lor p
IV. (¬p)∨q(\neg p) \lor q
Show answer without attempting

Answer: D

Q2

Discrete MathematicsMCQ1 mark−1/3 if wrong
Consider the first-order logic sentence F:∀x(∃yR(x,y))F: \forall x (\exists y R(x, y)). Assuming non-empty logical domains, which of the sentences below are implied by FF?

I. ∃y(∃xR(x,y))\exists y (\exists x R(x, y))
II. ∃y(∀xR(x,y))\exists y (\forall x R(x, y))
III. ∀y(∃xR(x,y))\forall y (\exists x R(x, y))
IV. ¬∃x(∀y¬R(x,y))\neg \exists x (\forall y \neg R(x, y))
Show answer without attempting

Answer: B

Q3

Linear AlgebraMCQ1 mark−1/3 if wrong
Let c1,…,cnc_1, \dots, c_n be scalars, not all zero, such that ∑i=1nciai=0\sum_{i=1}^n c_i a_i = 0 where aia_i are column vectors in Rn\mathbb{R}^n.

Consider the set of linear equations

Ax=bAx = b

where A=[a1,…,an]A = [a_1, \dots, a_n] and b=∑i=1naib = \sum_{i=1}^n a_i. The set of equations has
Show answer without attempting

Answer: C

Q4

Algorithm AnalysisMCQ1 mark−1/3 if wrong
Consider the following functions from positive integers to real numbers:

10,n,n,log⁡2n,100n10, \sqrt{n}, n, \log_2 n, \frac{100}{n}

The CORRECT arrangement of the above functions in increasing order of asymptotic complexity is:
Show answer without attempting

Answer: B

Q5

Algorithm DesignMCQ1 mark−1/3 if wrong
Consider the following table:
AlgorithmsDesign Paradigms
(P) Kruskal(i) Divide and Conquer
(Q) Quicksort(ii) Greedy
(R) Floyd-Warshall(iii) Dynamic Programming
Match the algorithms to the design paradigms they are based on.
Show answer without attempting

Answer: C

Q6

Tree Data StructuresMCQ1 mark−1/3 if wrong
Let TT be a binary search tree with 1515 nodes. The minimum and maximum possible heights of TT are:
Note: The height of a tree with a single node is 0.
Show answer without attempting

Answer: B

Q7

Number Representation and ArithmeticMCQ1 mark−1/3 if wrong
The nn-bit fixed-point representation of an unsigned real number XX uses ff bits for the fraction part. Let i=n−fi = n - f. The range of decimal values for XX in this representation is
Show answer without attempting

Answer: D

Q8

Linear Data StructuresMCQ1 mark−1/3 if wrong
Consider the C code fragment given below.
typedef struct node {
    int data;
    node* next;
} node;

void join(node* m, node* n) {
    node* p = n;
    while (p->next != NULL) {
        p = p->next;
    }
    p->next = m;
}
Assuming that mm and nn point to valid NULL-terminated linked lists, invocation of join will
Show answer without attempting

Answer: B

Q9

Number Representation and ArithmeticMCQ1 mark−1/3 if wrong
When two 8-bit numbers A7…A0A_7 \dots A_0 and B7…B0B_7 \dots B_0 in 2's complement representation (with A0A_0 and B0B_0 as the least significant bits) are added using a ripple-carry adder, the sum bits obtained are S7…S0S_7 \dots S_0 and the carry bits are C7…C0C_7 \dots C_0. An overflow is said to have occurred if
Show answer without attempting

Answer: C

Q10

Context Free LanguagesMCQ1 mark−1/3 if wrong
Consider the following context-free grammar over the alphabet Σ={a,b,c}\Sigma = \{a, b, c\} with SS as the start symbol:

S→abScT∣abcTS \to abScT \mid abcT
T→bT∣bT \to bT \mid b

Which one of the following represents the language generated by the above grammar?
Show answer without attempting

Answer: B

Q11

Instruction Set and AddressingMCQ1 mark−1/3 if wrong
Consider the C struct defined below:
struct data {
    int marks[100];
    char grade;
    int cnumber;
};
struct data student;
The base address of student is available in register R1. The field student.grade can be accessed efficiently using
Show answer without attempting

Answer: D

Q12

Intermediate CodeMCQ1 mark−1/3 if wrong
Consider the following intermediate program in three address code
p = a - b
q = p * c
p = u * v
q = p + q
Which one of the following corresponds to a static single assignment form of the above code?
Show answer without attempting

Answer: B

Q13

C ProgrammingMCQ1 mark−1/3 if wrong
Consider the following C code:
#include <stdio.h>
int *assignval(int *x, int val) {
    *x = val;
    return x;
}

void main () {
    int *x = malloc(sizeof(int));
    if (NULL == x) return;
    x = assignval(x, 0);
    if (x) {
        x = (int *)malloc(sizeof(int));
        if (NULL == x) return;
        x = assignval(x, 10);
    }
    printf("%d\n", *x);
    free(x);
}
The code suffers from which one of the following problems:
Show answer without attempting

Answer: D

Q14

Transport LayerMCQ1 mark−1/3 if wrong
Consider a TCP client and a TCP server running on two different machines. After completing data transfer, the TCP client calls close to terminate the connection and a FIN segment is sent to the TCP server. Server-side TCP responds by sending an ACK, which is received by the client-side TCP. As per the TCP connection state diagram (RFC 793), in which state does the client-side TCP connection wait for the FIN from the server-side TCP?
Show answer without attempting

Answer: D

Q15

Layering and SwitchingMCQ1 mark−1/3 if wrong
A sender S sends a message mm to receiver R, which is digitally signed by S with its private key. In this scenario, one or more of the following security violations can take place.

(I) S can launch a birthday attack to replace mm with a fraudulent message.
(II) A third party attacker can launch a birthday attack to replace mm with a fraudulent message.
(III) R can launch a birthday attack to replace mm with a fraudulent message.

Which of the following are possible security violations?
Show answer without attempting

Answer: B

Q16

Relational DesignMCQ1 mark−1/3 if wrong
The following functional dependencies hold true for the relational schema R{V,W,X,Y,Z}R\{V, W, X, Y, Z\}:

V→WV \to W
VW→XVW \to X
Y→VXY \to VX
Y→ZY \to Z

Which of the following is irreducible equivalent for this set of functional dependencies?
Show answer without attempting

Answer: A

Q17

Context Free LanguagesMCQ1 mark−1/3 if wrong
Consider the following grammar:

P→xQRSQ→yz∣zR→w∣εS→y\begin{aligned} P & \to xQRS \\ Q & \to yz \mid z \\ R & \to w \mid \varepsilon \\ S & \to y \end{aligned}

What is FOLLOW(Q)\text{FOLLOW}(Q)?
Show answer without attempting

Answer: C

Q18

Processes and ThreadsMCQ1 mark−1/3 if wrong
Threads of a process share
Show answer without attempting

Answer: D

Q19

Probability and StatisticsNAT1 mark
Let XX be a Gaussian random variable with mean 00 and variance σ2\sigma^2. Let Y=max⁡(X,0)Y = \max(X, 0) where max⁡(a,b)\max(a, b) is the maximum of aa and bb. The median of YY is ____________.
Show answer without attempting

Answer: 0.0

Q20

Discrete MathematicsNAT1 mark
Let TT be a tree with 1010 vertices. The sum of the degrees of all the vertices in TT is ____________.
Show answer without attempting

Answer: 18.0

Q21

Boolean Algebra and MinimizationNAT1 mark
Consider the Karnaugh map given below, where X represents "don't care" and blank represents 0.
dc \ ba00011110
00XX
011X
1111
10XX
Assume for all inputs (a,b,c,d)(a, b, c, d), the respective complements (a‾,b‾,c‾,d‾)(\overline{a}, \overline{b}, \overline{c}, \overline{d}) are also available. The above logic is implemented using 2-input NOR gates only. The minimum number of gates required is ____________.
Show answer without attempting

Answer: 1.0

Q22

Regular LanguagesNAT1 mark
Consider the language LL given by the regular expression (a+b)∗b(a+b)(a+b)^*b(a+b) over the alphabet {a,b}\{a, b\}. The smallest number of states needed in a deterministic finite-state automaton (DFA) accepting LL is ____________.
Show answer without attempting

Answer: 4.0

Q23

Relational QueriesNAT1 mark
Consider a database that has the relation schema EMP(EmpId, EmpName, and DeptName). An instance of the schema EMP and a SQL query on it are given below.
EmpIdEmpNameDeptName
1XYAAA
2XYBAA
3XYCAA
4XYDAA
5XYEAB
6XYFAB
7XYGAB
8XYHAC
9XYIAC
10XYJAC
11XYKAD
12XYLAD
13XYMAE
SELECT AVG(EC.Num)
FROM EC
WHERE (DeptName, Num) IN
    (SELECT DeptName, COUNT(EmpId) AS
                    EC(DeptName, Num)
     FROM EMP
     GROUP BY DeptName)
The output of executing the SQL query is ____________.
Show answer without attempting

Answer: 2.6

Q24

SchedulingNAT1 mark
Consider the following CPU processes with arrival times (in milliseconds) and length of CPU bursts (in milliseconds) as given below:
ProcessArrival timeBurst time
P107
P233
P355
P462
If the pre-emptive shortest remaining time first scheduling algorithm is used to schedule the processes, then the average waiting time across all processes is ____________ milliseconds.
Show answer without attempting

Answer: 3.0

Q25

Memory HierarchyNAT1 mark
Consider a two-level cache hierarchy with L1 and L2 caches. An application incurs 1.41.4 memory accesses per instruction on average. For this application, the miss rate of L1 cache is 0.10.1; the L2 cache experiences, on average, 77 misses per 10001000 instructions. The miss rate of L2 expressed correct to two decimal places is ____________.
Show answer without attempting

Answer: 0.05

Q26

Graph AlgorithmsMCQ2 marks−2/3 if wrong
Let G=(V,E)G = (V, E) be any connected undirected edge-weighted graph. The weights of the edges in EE are positive and distinct. Consider the following statements:

(I) Minimum Spanning Tree of GG is always unique.
(II) Shortest path between any two vertices of GG is always unique.

Which of the above statements is/are necessarily true?
Show answer without attempting

Answer: A

Q27

Concurrency and SynchronizationMCQ2 marks−2/3 if wrong
A multithreaded program PP executes with xx number of threads and uses yy number of locks for ensuring mutual exclusion while operating on shared memory locations. All locks in the program are non-reentrant, i.e., if a thread holds a lock ll, then it cannot re-acquire lock ll without releasing it. If a thread is unable to acquire a lock, it blocks until the lock becomes available. The minimum value of xx and the minimum value of yy together for which execution of PP can result in a deadlock are:
Show answer without attempting

Answer: D

Q28

CalculusMCQ2 marks−2/3 if wrong
The value of lim⁡x→1x7−2x5+1x3−3x2+2\lim_{x \to 1} \frac{x^7 - 2x^5 + 1}{x^3 - 3x^2 + 2}
Show answer without attempting

Answer: C

Q29

Discrete MathematicsMCQ2 marks−2/3 if wrong
Let pp, qq, and rr be propositions and the expression (p→q)→r(p \to q) \to r be a contradiction. Then, the expression (r→p)→q(r \to p) \to q is
Show answer without attempting

Answer: D

Q30

Linear AlgebraMCQ2 marks−2/3 if wrong
Let uu and vv be two vectors in R2\mathbb{R}^2 whose Euclidean norms satisfy ∥u∥=2∥v∥\|u\| = 2\|v\|. What is the value of α\alpha such that w=u+αvw = u + \alpha v bisects the angle between uu and vv?
Show answer without attempting

Answer: A

Q31

Linear AlgebraMCQ2 marks−2/3 if wrong
Let AA be n×nn \times n real valued square symmetric matrix of rank 22 with ∑i=1n∑j=1nAij2=50\sum_{i=1}^n \sum_{j=1}^n A_{ij}^2 = 50. Consider the following statements:

(I) One eigenvalue must be in [−5,5][-5, 5]
(II) The eigenvalue with the largest magnitude must be strictly greater than 55

Which of the above statements about eigenvalues of AA is/are necessarily CORRECT?
Show answer without attempting

Answer: B

Q32

Data Link LayerMCQ2 marks−2/3 if wrong
A computer network uses polynomials over GF(2)GF(2) for error checking with 88 bits as information bits and uses x3+x+1x^3 + x + 1 as the generator polynomial to generate the check bits. In this network, the message 0101101101011011 is transmitted as
Show answer without attempting

Answer: C

Q33

Sequential CircuitsMCQ2 marks−2/3 if wrong
Consider a combination of T and D flip-flops connected as shown below. The output of the D flip-flop is connected to the input of the T flip-flop and the output of the T flip-flop is connected to the input of the D flip-flop.

Initially, both Q0Q_0 and Q1Q_1 are set to 11 (before the 1st1^{\text{st}} clock cycle). The outputs
Question figure
Show answer without attempting

Answer: B

Q34

Context Free LanguagesMCQ2 marks−2/3 if wrong
If GG is a grammar with productions

S→SaS∣aSb∣bSa∣SS∣εS \to SaS \mid aSb \mid bSa \mid SS \mid \varepsilon

where SS is the start variable, then which one of the following strings is not generated by GG?
Show answer without attempting

Answer: D

Q35

RecursionMCQ2 marks−2/3 if wrong
Consider the following two functions.
void fun1(int n) {
    if (n == 0) return;
    printf("%d", n);
    fun2(n - 2);
    printf("%d", n);
}

void fun2(int n) {
    if (n == 0) return;
    printf("%d", n);
    fun1(++n);
    printf("%d", n);
}
The output printed when fun1(5) is called is
Show answer without attempting

Answer: A

Q36

RecursionMCQ2 marks−2/3 if wrong
Consider the C functions foo and bar given below:
int foo(int val) {
    int x = 0;
    while(val > 0) {
        x = x + foo(val--);
    }
    return val;
}

int bar(int val) {
    int x = 0;
    while(val > 0) {
        x = x + bar(val-1);
    }
    return val;
}
Invocations of foo(3) and bar(3) will result in:
Show answer without attempting

Answer: C

Q37

Context Free LanguagesMCQ2 marks−2/3 if wrong
Consider the context-free grammars over the alphabet {a,b,c}\lbrace a, b, c \rbrace given below. SS and TT are non-terminals.

G1:S→aSb∣T,T→cT∣εG_1: S \to aSb \mid T, T \to cT \mid \varepsilon
G2:S→bSa∣T,T→cT∣εG_2: S \to bSa \mid T, T \to cT \mid \varepsilon

The language L(G1)∩L(G2)L(G_1) \cap L(G_2) is
Show answer without attempting

Answer: B

Q38

Context Free LanguagesMCQ2 marks−2/3 if wrong
Consider the following languages over the alphabet Σ={a,b,c}\Sigma = \lbrace a, b, c \rbrace. Let L1={anbncm∣m,n≥0}L_1 = \lbrace a^n b^n c^m \mid m, n \ge 0 \rbrace and L2={ambncn∣m,n≥0}L_2 = \lbrace a^m b^n c^n \mid m, n \ge 0 \rbrace.

Which of the following are context-free languages?

I. L1∪L2L_1 \cup L_2
II. L1∩L2L_1 \cap L_2
Show answer without attempting

Answer: A

Q39

ComputabilityMCQ2 marks−2/3 if wrong
Let AA and BB be finite alphabets and let #\# be a symbol outside both AA and BB. Let ff be a total function from A∗A^* to B∗B^*. We say ff is computable if there exists a Turing machine MM which given an input xx in A∗A^*, always halts with f(x)f(x) on its tape. Let LfL_f denote the language {x#f(x)∣x∈A∗}\lbrace x\#f(x) \mid x \in A^* \rbrace.
Which of the following statements is true:
Show answer without attempting

Answer: A

Q40

Memory ManagementMCQ2 marks−2/3 if wrong
Recall that Belady's anomaly is that the page-fault rate may increase as the number of allocated frames increases. Now, consider the following statements:

S1: Random page replacement algorithm (where a page chosen at random is replaced) suffers from Belady's anomaly
S2: LRU page replacement algorithm suffers from Belady's anomaly

Which of the following is CORRECT?
Show answer without attempting

Answer: B

Q41

Relational QueriesMCQ2 marks−2/3 if wrong
Consider a database that has the relation schemas EMP(EmpId, EmpName, DeptId), and DEPT(DeptName, DeptId). Note that the DeptId can be permitted to be NULL in the relation EMP.
Consider the following queries on the database expressed in tuple relational calculus.

(I) {t∣∃u∈EMP(t[EmpName]=u[EmpName]∧∀v∈DEPT(t[DeptId]≠v[DeptId]))}\lbrace t \mid \exists u \in \text{EMP}(t[\text{EmpName}] = u[\text{EmpName}] \land \forall v \in \text{DEPT}(t[\text{DeptId}] \neq v[\text{DeptId}])) \rbrace
(II) {t∣∃u∈EMP(t[EmpName]=u[EmpName]∧∃v∈DEPT(t[DeptId]≠v[DeptId]))}\lbrace t \mid \exists u \in \text{EMP}(t[\text{EmpName}] = u[\text{EmpName}] \land \exists v \in \text{DEPT}(t[\text{DeptId}] \neq v[\text{DeptId}])) \rbrace
(III) {t∣∃u∈EMP(t[EmpName]=u[EmpName]∧∃v∈DEPT(t[DeptId]=v[DeptId]))}\lbrace t \mid \exists u \in \text{EMP}(t[\text{EmpName}] = u[\text{EmpName}] \land \exists v \in \text{DEPT}(t[\text{DeptId}] = v[\text{DeptId}])) \rbrace

Which of the above queries are safe?
Show answer without attempting

Answer: D

Q42

TransactionsMCQ2 marks−2/3 if wrong
In a database system, unique timestamps are assigned to each transaction using Lamport's logical clock. Let TS(T1)TS(T_1) and TS(T2)TS(T_2) be the timestamps of transactions T1T_1 and T2T_2 respectively. Besides, T1T_1 holds a lock on the resource R, and T2T_2 has requested a conflicting lock on the same resource R. The following algorithm is used to prevent deadlocks in the database system assuming that a killed transaction is restarted with the same timestamp.

if TS(T2)<TS(T1) thenT1 is killedelse T2 waits.\begin{aligned} & \text{if } TS(T_2) < TS(T_1) \text{ then} \\ & \quad T_1 \text{ is killed} \\ & \text{else } T_2 \text{ waits.} \end{aligned}

Assume any transaction that is not killed terminates eventually. Which of the following is TRUE about the database system that uses the above algorithm to prevent deadlocks?
Show answer without attempting

Answer: A

Q43

ParsingNAT2 marks
Consider the following grammar:
stmt -> if expr then expr else expr; stmt | ε
expr -> term relop term | term
term -> id | number
id -> a | b | c
number -> [0-9]
where relop is a relational operator (e.g., <,>,…<, >, \dots), ε\varepsilon refers to the empty statement, and if, then, else are terminals.

Consider a program PP following the above grammar containing ten if terminals. The number of control flow paths in PP is ____________. For example, the program
if e1 then e2 else e3
has 2 control flow paths, e1→e2e_1 \to e_2 and e1→e3e_1 \to e_3.
Show answer without attempting

Answer: 1024.0

Q44

Discrete MathematicsNAT2 marks
In a RSA cryptosystem, a participant A uses two prime numbers p=13p = 13 and q=17q = 17 to generate her public and private keys. If the public key of A is 3535, then the private key of A is ____________.
Show answer without attempting

Answer: 11.0

Q45

Layering and SwitchingNAT2 marks
The values of parameters for the Stop-and-Wait ARQ protocol are as given below:

Bit rate of the transmission channel = 1 Mbps1\text{ Mbps}.
Propagation delay from sender to receiver = 0.75 ms0.75\text{ ms}.
Time to process a frame = 0.25 ms0.25\text{ ms}.
Number of bytes in the information frame = 19801980.
Number of bytes in the acknowledge frame = 2020.
Number of overhead bytes in the information frame = 2020.

Assume that there are no transmission errors. Then, the transmission efficiency (expressed in percentage) of the Stop-and-Wait ARQ protocol for the above parameters is ____________ (correct to 2 decimal places).
Show answer without attempting

Answer: 86.5 to 89.5

Q46

Relational QueriesNAT2 marks
Consider a database that has the relation schema CR(StudentName, CourseName). An instance of the schema CR is as given below.
StudentNameCourseName
SACA
SACB
SACC
SBCB
SBCC
SCCA
SCCB
SCCC
SDCA
SDCB
SDCC
SDCD
SECD
SECA
SECB
SFCA
SFCB
SFCC
The following query is made on the database.

T1←πCourseName(σStudentName=′SA′(CR))T1 \leftarrow \pi_{\text{CourseName}}(\sigma_{\text{StudentName} = '\text{SA}'}(\text{CR}))
T2←CR÷T1T2 \leftarrow \text{CR} \div T1

The number of rows in T2T2 is ____________.
Show answer without attempting

Answer: 4.0

Q47

Discrete MathematicsNAT2 marks
The number of integers between 11 and 500500 (both inclusive) that are divisible by 33 or 55 or 77 is ____________.
Show answer without attempting

Answer: 271.0

Q48

Searching Sorting and HashingNAT2 marks
Let AA be an array of 3131 numbers consisting of a sequence of 00's followed by a sequence of 11's. The problem is to find the smallest index ii such that A[i]A[i] is 11 by probing the minimum number of locations in AA. The worst case number of probes performed by an optimal algorithm is ____________.
Show answer without attempting

Answer: 5.0

Q49

Instruction Set and AddressingNAT2 marks
Consider a RISC machine where each instruction is exactly 44 bytes long. Conditional and unconditional branch instructions use PC-relative addressing mode with Offset specified in bytes to the target location of the branch instruction. Further the Offset is always with respect to the address of the next instruction in the program sequence. Consider the following instruction sequence

Instr. No.‾Instruction‾i:add R2,R3,R4i+1:sub R5,R6,R7i+2:cmp R1,R9,R10i+3:beq R1,Offset\begin{array}{rll} \underline{\text{Instr. No.}} & & \underline{\text{Instruction}} \\ i & : & \text{add } R2, R3, R4 \\ i+1 & : & \text{sub } R5, R6, R7 \\ i+2 & : & \text{cmp } R1, R9, R10 \\ i+3 & : & \text{beq } R1, \text{Offset} \end{array}

If the target of the branch instruction is ii, then the decimal value of the Offset is ____________.
Show answer without attempting

Answer: -16.0

Q50

Instruction PipeliningNAT2 marks
Instruction execution in a processor is divided into 55 stages, Instruction Fetch (IF), Instruction Decode (ID), Operand Fetch (OF), Execute (EX), and Write Back (WB). These stages take 5,4,20,10,5, 4, 20, 10, and 33 nanoseconds (ns) respectively. A pipelined implementation of the processor requires buffering between each pair of consecutive stages with a delay of 2 ns2\text{ ns}. Two pipelined implementations of the processor are contemplated:

(i) a naive pipeline implementation (NP) with 55 stages and
(ii) an efficient pipeline (EP) where the OF stage is divided into stages OF1 and OF2 with execution times of 12 ns12\text{ ns} and 8 ns8\text{ ns} respectively.

The speedup (correct to two decimal places) achieved by EP over NP in executing 2020 independent instructions with no hazards is ____________.
Show answer without attempting

Answer: 1.49 to 1.52

Q51

Memory HierarchyNAT2 marks
Consider a 2-way set associative cache with 256256 blocks and uses LRU replacement. Initially the cache is empty. Conflict misses are those misses which occur due to contention of multiple blocks for the same cache set. Compulsory misses occur due to first time access to the block. The following sequence of accesses to memory blocks

(0,128,256,128,0,128,256,128,1,129,257,129,1,129,257,129)(0, 128, 256, 128, 0, 128, 256, 128, 1, 129, 257, 129, 1, 129, 257, 129)

is repeated 1010 times. The number of conflict misses experienced by the cache is ____________.
Show answer without attempting

Answer: 76.0

Q52

Instruction Set and AddressingNAT2 marks
Consider the expression (a−1)∗(((b+c)/3)+d)(a-1)*(((b+c)/3)+d). Let X be the minimum number of registers required by an optimal code generation (without any register spill) algorithm for a load/store architecture, in which (i) only load and store instructions can have memory operands and (ii) arithmetic instructions can have only register or immediate operands. The value of X is ____________.
Show answer without attempting

Answer: 2.0

Q53

C ProgrammingNAT2 marks
Consider the following C program.
#include <stdio.h>
#include <string.h>

void printlength(char *s, char *t) {
    unsigned int c = 0;
    int len = ((strlen(s) - strlen(t)) > c) ? strlen(s): strlen(t);
    printf("%d\n", len);
}

void main() {
    char *x = "abc";
    char *y = "defgh";
    printlength(x,y);
}
Recall that strlen is defined in string.h as returning a value of type size_t, which is an unsigned int. The output of the program is ____________.
Show answer without attempting

Answer: 3.0

Q54

Memory HierarchyNAT2 marks
A cache memory unit with capacity of NN words and block size of BB words is to be designed. If it is designed as a direct mapped cache, the length of the TAG field is 1010 bits. If the cache unit is now designed as a 1616-way set-associative cache, the length of the TAG field is ____________ bits.
Show answer without attempting

Answer: 14.0

Q55

C ProgrammingNAT2 marks
The output of executing the following C program is ____________.
#include <stdio.h>

int total(int v) {
    static int count = 0;
    while(v) {
        count += v&1;
        v >>= 1;
    }
    return count;
}

void main() {
    static int x = 0;
    int i = 5;
    for(; i > 0; i--) {
        x = x + total(i);
    }
    printf("%d\n", x);
}
Show answer without attempting

Answer: 23.0

Q56

Verbal AptitudeMCQ1 mark−1/3 if wrong
After Rajendra Chola returned from his voyage to Indonesia, he ____________ to visit the temple in Thanjavur.
Show answer without attempting

Answer: C

Q57

Verbal AptitudeMCQ1 mark−1/3 if wrong
Research in the workplace reveals that people work for many reasons ____________.
Show answer without attempting

Answer: D

Q58

Analytical AptitudeMCQ1 mark−1/3 if wrong
Rahul, Murali, Srinivas and Arul are seated around a square table. Rahul is sitting to the left of Murali. Srinivas is sitting to the right of Arul. Which of the following pairs are seated opposite each other?
Show answer without attempting

Answer: C

Q59

Quantitative AptitudeMCQ1 mark−1/3 if wrong
Find the smallest number yy such that y×162y \times 162 is a perfect cube.
Show answer without attempting

Answer: D

Q60

Quantitative AptitudeMCQ1 mark−1/3 if wrong
The probability that a kk-digit number does NOT contain the digits 0,5,0, 5, or 99 is
Show answer without attempting

Answer: C

Q61

Verbal AptitudeMCQ2 marks−2/3 if wrong
"The hold of the nationalist imagination on our colonial past is such that anything inadequately or improperly nationalist is just not history."

Which of the following statements best reflects the author's opinion?
Show answer without attempting

Answer: B

Q62

Analytical AptitudeMCQ2 marks−2/3 if wrong
Six people are seated around a circular table. There are at least two men and two women. There are at least three right-handed persons. Every woman has a left-handed person to her immediate right. None of the women are right-handed. The number of women at the table is
Show answer without attempting

Answer: A

Q63

Quantitative AptitudeMCQ2 marks−2/3 if wrong
The expression (x+y)−∣x−y∣2\frac{(x+y) - |x-y|}{2} is equal to
Show answer without attempting

Answer: B

Q64

Quantitative AptitudeMCQ2 marks−2/3 if wrong
Arun, Gulab, Neel and Shweta must choose one shirt each from a pile of four shirts coloured red, pink, blue and white respectively. Arun dislikes the colour red and Shweta dislikes the colour white. Gulab and Neel like all the colours. In how many different ways can they choose the shirts so that no one has a shirt with a colour he or she dislikes?
Show answer without attempting

Answer: D

Q65

Spatial AptitudeMCQ2 marks−2/3 if wrong
A contour line joins locations having the same height above the mean sea level. The following is a contour plot of a geographical region. Contour lines are shown at 25 m25\text{ m} intervals in this plot. If in a flood, the water level rises to 525 m525\text{ m}, which of the villages P, Q, R, S, T get submerged?
Question figure
Show answer without attempting

Answer: C

0/650 correct0 marks

More GATE CS papers