Organised by IIT Guwahati

GATE 2026 CS (Computer Science) Session 2 question paper with solutions

62 questions with the official answer key and a worked solution for each. Try a question before opening its answer.

Practise this paper with instant checking
Q1MCQ1 mark · -1/3· Easy

Expedite, Hasten, Hurry, __________ Fill the blank by choosing a word with a meaning similar to that of the words given above.

  1. (A)Accelerate
  2. (B)Retard
  3. (C)Provide
  4. (D)Disable
Answer: A - show solution

Expedite, hasten and hurry all mean to make something happen faster. Accelerate means to increase speed, so it fits the group. Retard means to slow down (opposite), provide means to supply, and disable means to make unable. Answer: (A) Accelerate.

Concept: Synonym grouping. Identify the common meaning of the given words (speeding up) and pick the option sharing it. The trap is retard, which belongs to the same topic of speed but is the antonym.

Q3MCQ1 mark · -1/3· Easy

A day can only be cloudy or sunny. The probability of a day being cloudy is 0.5, independent of the condition on other days. What is the probability that in any given four days, there will be three cloudy days and one sunny day?

  1. (A)1/4
  2. (B)3/4
  3. (C)2/3
  4. (D)3/8
Answer: A - show solution

This is a binomial count with n = 4, p = 0.5. P(exactly 3 cloudy) = C(4,3) x (0.5)^3 x (0.5)^1 = 4 x 1/16 = 1/4. Answer: (A) 1/4.

Concept: Binomial probability: choose which of the four days is sunny (4 ways), each specific pattern has probability 1/16. The trap is forgetting the C(4,3) factor and answering 1/16, or confusing with 3/8 which is the value for exactly 2 of 4.

Q4MCQ1 mark · -1/3· Easy

The values of Stock A and Stock B on a particular day are Rs. 50 and Rs. 80, respectively. An investor invests Rs. 100 in Stock A and Rs. 80 in Stock B. He sells all the stocks the next day when the value of Stock A is Rs. 55 and Stock B is Rs. 70. The profit made by the investor is Rs. ________

  1. (A)0
  2. (B)5
  3. (C)10
  4. (D)20
Answer: A - show solution

Rs. 100 buys 100/50 = 2 shares of A; Rs. 80 buys 80/80 = 1 share of B. Total cost = 180. Next day: 2 x 55 + 1 x 70 = 110 + 70 = 180. Profit = 180 - 180 = 0. Answer: (A) 0.

Concept: Convert money invested into number of shares, then revalue. The gain of Rs. 10 on A exactly offsets the loss of Rs. 10 on B. The trap is applying the per-share change (+5, -10) directly without scaling by the number of shares.

Q5MCQ1 mark · -1/3· Easy

'When it is raining, peacocks dance.' Based only on this sentence, which one of the following options is necessarily true?

  1. (A)Peacocks dance only when it is raining.
  2. (B)When peacocks dance, it is raining.
  3. (C)When peacocks are not dancing, it is not raining.
  4. (D)When it is not raining, peacocks do not dance.
Answer: C - show solution

The statement is: raining -> dance. The only statement logically equivalent to an implication is its contrapositive: not dance -> not raining, i.e. when peacocks are not dancing, it is not raining. (A) and (B) are the converse, (D) is the inverse; neither follows. Answer: (C).

Concept: Tests implication versus converse, inverse and contrapositive. Only the contrapositive is guaranteed. The usual trap is picking the converse or inverse, which sound natural but are not implied.

Q6MCQ2 marks · -2/3· Easy

Water : P :: Food : Q Choose the P and Q combination from the options below to form a meaningful analogy.

  1. (A)P = Thirst; Q = Hunger
  2. (B)P = Drink; Q = Hunger
  3. (C)P = Thirst; Q = Satiated
  4. (D)P = Wet; Q = Critic
Answer: A - show solution

Water quenches thirst; food satisfies hunger. The relation is 'remedy : need', so P = Thirst and Q = Hunger. (B) mixes an action (drink) with a need; (C) mixes a need with a resulting state. Answer: (A).

Concept: Analogy questions require the same relation on both sides. Water relieves thirst as food relieves hunger. The trap is options where each pair is related to its word but via different relations.

Q8MCQ2 marks · -2/3· Moderate

Figures (i) and (ii) represent intercity highway systems. The black dots represent cities and the line segments between them represent intercity highways. A salesperson needs to make a trip. She needs to start from a city, visit each of the remaining cities exactly once, and finally return to the same city from which she started. Figure (i): 16 cities arranged in a 4 x 4 square grid, each city joined by a highway to its horizontal and vertical neighbours. Figure (ii): 5 cities P, Q, R, S, T with highways P-Q, P-R, P-S, R-T, S-T and Q-T. Which one of the following options is then true?

  1. (A)Such a trip is possible for (i), but not for (ii).
  2. (B)Such a trip is possible for (ii), but not for (i).
  3. (C)Such a trip is possible for both (i) and (ii).
  4. (D)Such a trip is possible neither for (i) nor for (ii).
Answer: A - show solution

The trip is a Hamiltonian cycle. (i): a 4 x 4 grid has one - go along the top row, snake down and back through columns 2 to 4, then return up column 1. So (i) works. (ii): Q, R and S each have degree 2, so both their edges must be in the cycle: Q-P, Q-T, R-P, R-T, S-P, S-T. That forces P to have 3 cycle edges, impossible (each vertex has exactly 2 in a cycle). So (ii) fails. Answer: (A).

Concept: Hamiltonian cycle reasoning: degree-2 vertices force their edges into the cycle, which quickly exposes contradictions. The trap is confusing this with an Euler circuit (every edge once) and checking degree parity instead.

Q9MCQ2 marks · -2/3· Easy

The figure in Panel I is a grid of cells with four rows and four columns. The numbers on the top and on the left represent the number of cells that are to be shaded in that column and row, respectively. Column counts (left to right): 2, 2, 2, 2. Row counts (top to bottom): 3, 1, 2, 2. Which one of the following shaded grids is correct? (X = shaded, . = unshaded; rows top to bottom) (i) X.XX / .X.X / ..X. / XX.. (ii) X.XX / .X.. / ..XX / XX.. (iii) X.XX / .XX. / ..X. / XX.. (iv) X.XX / .X.. / ..X. / XX.X

  1. (A)(i)
  2. (B)(ii)
  3. (C)(iii)
  4. (D)(iv)
Answer: B - show solution

Check row counts first: (i) has rows 3,2,1,2 - fails. (iii) has rows 3,2,1,2 - fails. (iv) has rows 3,1,1,3 - fails. (ii) has rows 3,1,2,2. Its columns: col1 rows 1,4 = 2; col2 rows 2,4 = 2; col3 rows 1,3 = 2; col4 rows 1,3 = 2. All constraints hold. Answer: (B) (ii).

Concept: Constraint checking (a nonogram): eliminate options by verifying row totals, then confirm column totals. The trap is checking only rows or only columns.

Q10MCQ2 marks · -2/3· Easy

An unbiased six-faced dice whose faces are marked with numbers 1, 2, 3, 4, 5, and 6 is rolled twice in succession and the number on the top face is recorded each time. The probability that the sum of the two recorded numbers is a prime number is ________

  1. (A)3/36
  2. (B)13/36
  3. (C)15/36
  4. (D)19/36
Answer: C - show solution

Possible prime sums are 2, 3, 5, 7, 11. Number of ordered outcomes: sum 2 -> 1, sum 3 -> 2, sum 5 -> 4, sum 7 -> 6, sum 11 -> 2. Total = 15 out of 36. Answer: (C) 15/36.

Concept: Counting ordered outcomes of two dice. The trap is forgetting 2 is prime or counting (1,2) and (2,1) as one outcome.

Q11MCQ1 mark · -1/3· Easy

For two different persons x and y, the predicate M(x, y) denotes that x knows y. Consider the following statement. There is a person who does not know anyone else, but that person is known by everyone else. Which one of the following expressions represents the above statement?

  1. (A)(∃y)(∀x) ((x ≠ y) → (M(x, y) ∧ ¬M(y, x)))
  2. (B)(∀y)(∃x) ((x ≠ y) → (M(x, y) ∧ ¬M(y, x)))
  3. (C)(∃y)(∃x) ((x ≠ y) → (M(x, y) ∧ ¬M(y, x)))
  4. (D)(∀y)(∀x) ((x ≠ y) → (M(x, y) ∧ ¬M(y, x)))
Answer: A - show solution

Let y be the special person: 'there exists y'. For every other person x (for all x with x ≠ y): x knows y, M(x, y), and y does not know x, ¬M(y, x). This is (∃y)(∀x)((x ≠ y) → (M(x, y) ∧ ¬M(y, x))). Answer: (A).

Concept: Translating English to predicate logic: one specific person (∃) related in a fixed way to all others (∀), with the guard written as an implication. The trap is swapping the quantifier order, which changes the meaning, or using ∃x which makes the statement nearly vacuous.

Q12MCQ1 mark · -1/3· Easy

The set T represents various traversals over binary tree. The set S represents the order of visiting nodes during a traversal. T S I: Inorder L: left subtree, node, right subtree II: Preorder M: node, left subtree, right subtree III: Postorder N: left subtree, right subtree, node Which one of the following is the correct match from T to S?

  1. (A)I → L, II → M, III → N
  2. (B)I → M, II → L, III → N
  3. (C)I → N, II → M, III → L
  4. (D)I → L, II → N, III → M
Answer: A - show solution

Inorder visits left subtree, node, right subtree (L). Preorder visits node first, then left, then right (M). Postorder visits left, right, then node (N). Answer: (A) I → L, II → M, III → N.

Concept: Definitions of the three depth-first traversals: the prefix (pre/in/post) tells where the node is visited relative to its subtrees. Mixing up pre and post is the common slip.

Q13MCQ1 mark · -1/3· Easy

Which one of the following statements is equivalent to the following assertion? Turing machine M decides the language L ⊆ {0,1}*

  1. (A)Turing machine M halts on all input strings in {0,1}*
  2. (B)Turing machine M accepts all input strings in L
  3. (C)Turing machine M rejects all input strings in {0,1}* - L
  4. (D)Turing machine M accepts all input strings in L and rejects all input strings in {0,1}* - L
Answer: D - show solution

M decides L means M halts on every input, accepting exactly the strings in L and rejecting every string not in L. (A) only says it halts (it could decide some other language). (B) alone allows looping on non-members (that is recognising). (C) alone says nothing about members. (D) states both halves, and accepting or rejecting implies halting. Answer: (D).

Concept: Deciding versus recognising: a decider must halt with the correct verdict on every input. The trap is (B), which describes a recogniser that may loop forever on strings outside L.

Q14MCQ1 mark · -1/3· Easy

The probability density function f(x) of a random variable X which takes real values is f(x) = (1 / (3√(2π))) exp(-x²/18), x ∈ (-∞, +∞) Which one of the following statements is correct about the random variable X?

  1. (A)X is an exponential random variable
  2. (B)X is a normal random variable
  3. (C)X is a Poisson random variable
  4. (D)X is a uniform random variable
Answer: B - show solution

The normal density is (1/(σ√(2π))) exp(-(x - μ)²/(2σ²)). With μ = 0 and σ = 3: 2σ² = 18 and the constant is 1/(3√(2π)), matching exactly. So X ~ N(0, 9). Poisson is discrete, exponential is supported on x ≥ 0, uniform has a constant density. Answer: (B).

Concept: Recognise the Gaussian form exp(-x²/(2σ²)) with matching normalisation. The trap is being misled by 'exp' into choosing exponential, whose density is λe^(-λx) on x ≥ 0 only.

Q15MCQ1 mark · -1/3· Easy

In the context of DBMS, consider the two sets T and S given below. T S I: Logical schema L: Views II: Physical schema M: File organization and indexes III: External schema N: Relations Which one of the following is the correct match from T to S?

  1. (A)I → L, II → M, III → N
  2. (B)I → M, II → L, III → N
  3. (C)I → N, II → M, III → L
  4. (D)I → N, II → L, III → M
Answer: C - show solution

In the three-schema architecture: the logical (conceptual) schema describes the relations; the physical schema describes storage - file organization and indexes; the external schema describes the views presented to users. So I → N, II → M, III → L. Answer: (C).

Concept: Three levels of data abstraction (ANSI/SPARC). The trap is mapping the external schema to relations instead of views.

Q16MCQ1 mark · -1/3· Easy

Which one of the following options is not a property of Boolean Algebra? Note: + is OR operation, . is AND operation, and ' is NOT operation

  1. (A)a + b = b + a
  2. (B)a . a' = 1
  3. (C)a + a' = 1
  4. (D)a . b = b . a
Answer: B - show solution

(A) and (D) are commutative laws. (C) is the complement law for OR. The complement law for AND is a . a' = 0, not 1, so (B) is false. Answer: (B).

Concept: Complement laws: a + a' = 1 and a . a' = 0. The trap is reading quickly and treating both complement laws as giving 1.

Q17MCQ1 mark · -1/3· Easy

In C runtime environment, which one of the following is stored in heap?

  1. (A)A static variable declared inside a function
  2. (B)An array of integers declared inside a function
  3. (C)A dynamically allocated array of integers created using malloc() function call
  4. (D)Return address of a function
Answer: C - show solution

Static variables live in the data/BSS segment. A local array is on the stack in the function's activation record. The return address is also on the stack. Memory obtained with malloc() comes from the heap. Answer: (C).

Concept: Memory layout of a C program: text, data/BSS, stack, heap. The trap is (A): a static local has function scope but static storage duration, so it is in the data segment, not the stack or heap.

Q18MCQ1 mark · -1/3· Easy

Consider the following two statements about interrupt handling mechanisms in a CPU. S1: In non-vectored interrupt mechanism, it usually takes more time to start the Interrupt Service Routine (ISR) when compared to that in a vectored interrupt mechanism. S2: In daisy-chain interrupt mechanism, the CPU polls all the input devices individually to determine the source of the interrupt. Which one of the following options is correct with respect to S1 and S2?

  1. (A)Both S1 and S2 are true
  2. (B)Both S1 and S2 are false
  3. (C)S1 is true and S2 is false
  4. (D)S1 is false and S2 is true
Answer: C - show solution

S1: In a non-vectored scheme the CPU jumps to a fixed location and software must identify the source, so starting the right ISR takes longer than with a vector supplied by the device. True. S2: In a daisy chain the interrupt-acknowledge signal propagates through devices in hardware and the first requesting device places its vector on the bus; the CPU does not poll each device. Polling is a different scheme. False. Answer: (C).

Concept: Distinguish vectored, non-vectored, polling and daisy-chain priority. The trap is treating daisy chaining as software polling; it is a hardware priority chain.

Q19MCQ1 mark · -1/3· Easy

Consider the following three ANSI-C programs, P1, P2, and P3. Which one of the following statements is true?

/* P1 */
#include <stdio.h>
int a=5;
int main(){
  int a=7;
  return(0);
}

/* P2 */
#include <stdio.h>
int main(){
  int a=5;
  int a=7;
  return(0);
}

/* P3 */
#include <stdio.h>
int main(){
  int a=5;
  float a=7;
  return(0);
}
  1. (A)Only P1 will compile without any error
  2. (B)Only P2 will compile without any error
  3. (C)Only P3 will compile without any error
  4. (D)All three programs P1, P2, and P3 will compile without any error
Answer: A - show solution

P1: the global a and the local a are in different scopes; the local one shadows the global. Legal. P2: a is defined twice in the same block - redefinition error. P3: a is declared as int and then as float in the same block - conflicting types error. Only P1 compiles. Answer: (A).

Concept: Scope and redeclaration rules in C: an inner scope may shadow an outer name, but the same block cannot define a name twice, whatever the type. The trap is thinking a different type makes P3 legal.

Q20MCQ1 mark · -1/3· Easy

Consider concurrent execution of two transactions T1 and T2 in a DBMS, both of which access a data object X. For these two transactions to not conflict on X, which one of the following statements must be true?

  1. (A)Both T1 and T2 only read X
  2. (B)T1 reads X and T2 writes X
  3. (C)T1 writes X and T2 reads X
  4. (D)Both T1 and T2 write X
Answer: A - show solution

Two operations on the same item by different transactions conflict if at least one of them is a write. Read-write, write-read and write-write all conflict. Only read-read does not. Answer: (A).

Concept: Definition of conflicting operations used in conflict serializability. The trap is thinking only write-write conflicts.

Q21MCQ1 mark · -1/3· Easy

Consider a file of size 4 million bytes being transferred between two hosts connected via a path consisting of three consecutive links of bandwidth 2 Mbps, 500 kbps, and 1 Mbps, respectively. All processing delays and propagation delays are negligible. Assume that there is no other background traffic over the path and no other additional overhead to transfer the file. Which one of the following is the total time (in seconds) to transfer the file? Note: 1M = 10⁶, 1k = 10³

  1. (A)731
  2. (B)64
  3. (C)8
  4. (D)16
Answer: B - show solution

File size = 4 x 10⁶ bytes = 32 x 10⁶ bits. With negligible delays and the data streamed along the path, end-to-end throughput equals the bottleneck link rate, min(2 Mbps, 500 kbps, 1 Mbps) = 500 kbps. Time = 32 x 10⁶ / 5 x 10⁵ = 64 s. Answer: (B) 64.

Concept: End-to-end throughput of a path is limited by its slowest link. Traps: forgetting bytes-to-bits (giving 8 or 16), or summing per-link transfer times as if the whole file were stored and forwarded at each hop.

Q22MCQ1 mark · -1/3· Easy

Which one of the following protocols may need to broadcast some of its messages?

  1. (A)SMTP
  2. (B)FTP
  3. (C)DHCP
  4. (D)HTTP
Answer: C - show solution

A DHCP client has no IP address and does not know the server's address, so DHCPDISCOVER (and typically DHCPREQUEST) is sent to the broadcast address 255.255.255.255. SMTP, FTP and HTTP run over TCP connections to a known server and are unicast. Answer: (C) DHCP.

Concept: Broadcast is needed when the destination is unknown, as in address configuration. TCP-based application protocols are always unicast.

Q23MCQ1 mark · -1/3· Easy

Which one of the following CPU scheduling algorithms cannot be preemptive?

  1. (A)Shortest Remaining Time First (SRTF) Scheduling
  2. (B)First Come First Serve (FCFS) Scheduling
  3. (C)Round Robin Scheduling
  4. (D)Priority Scheduling
Answer: B - show solution

SRTF is the preemptive version of SJF. Round Robin preempts on quantum expiry. Priority scheduling can be preemptive or not. FCFS runs each process to completion (or until it blocks) in arrival order and never preempts. Answer: (B).

Concept: Know which schedulers are inherently preemptive, inherently non-preemptive, or either. The trap is priority scheduling, which has both variants.

Q24MCQ1 mark · -1/3· Easy

Consider the following functions, where n is a positive integer. n^(1/3), log(n), log(n!), 2^(log(n)) Which one of the following options lists the functions in increasing order of asymptotic growth rate? Note: Assume the base of log to be 2.

  1. (A)log(n), n^(1/3), 2^(log(n)), log(n!)
  2. (B)n^(1/3), log(n), log(n!), 2^(log(n))
  3. (C)log(n), n^(1/3), log(n!), 2^(log(n))
  4. (D)2^(log(n)), n^(1/3), log(n), log(n!)
Answer: A - show solution

2^(log₂ n) = n. log(n!) = Θ(n log n) by Stirling. Any polynomial beats a logarithm, so log n < n^(1/3) < n. Hence log n, n^(1/3), 2^(log n), log(n!). Answer: (A).

Concept: Simplify before comparing: 2^(log₂ n) is just n, and log(n!) is Θ(n log n). The trap is treating 2^(log n) as exponential and putting it last.

Q25MSQ1 mark · no negative· Easy

Which of the following can be recurrence relation(s) corresponding to an algorithm with time complexity Θ(n)?

  1. (A)T(n) = T(n - 1) + 1, T(1) = 1
  2. (B)T(n) = 2T(n/2) + 1, T(1) = 1
  3. (C)T(n) = 2T(n/2) + n, T(1) = 1
  4. (D)T(n) = T(n - 1) + n, T(1) = 1
Answer: A, B - show solution

(A) unrolls to T(n) = n: Θ(n). (B) by the master theorem, a = 2, b = 2, n^(log_b a) = n dominates f(n) = 1, so Θ(n). (C) f(n) = n equals n^(log_b a), so Θ(n log n). (D) sums 1 + 2 + ... + n = Θ(n²). Answer: (A) and (B).

Concept: Solving recurrences by unrolling and the master theorem. The trap is (B): two half-size calls with constant work still total Θ(n), not Θ(log n).

Q26MSQ1 mark · no negative· Moderate

Let R be a binary relation on the set {1, 2, ..., 10}, where (x, y) ∈ R if the product of x and y is square of an integer. Which of the following properties is/are satisfied by R?

  1. (A)Reflexive
  2. (B)Symmetric
  3. (C)Transitive
  4. (D)Antisymmetric
Answer: A, B, C - show solution

Reflexive: x·x = x² is a square. Symmetric: xy = yx. Transitive: if xy = a² and yz = b², then xz·y² = (ab)², so xz = (ab/y)² is a rational square that is an integer, hence a perfect square. Antisymmetric fails: (1,4) and (4,1) are both in R but 1 ≠ 4. Answer: (A), (B) and (C).

Concept: R relates numbers with the same square-free part, so it is an equivalence relation. The trap is doubting transitivity, or assuming antisymmetry without testing a pair like (1,4).

Q27MSQ1 mark · no negative· Easy

For a real number a, let I(a) = ∫ from -1 to 1 of (3x² - ax + 1) dx. Which of the following statements is/are true?

  1. (A)The value of I(a) is independent of the value of a
  2. (B)The value of I(a) can vary with the value of a
  3. (C)There exists a ∈ (-∞, +∞) such that I(a) is a positive real number
  4. (D)There exists a ∈ (-∞, +∞) such that I(a) is a negative real number
Answer: A, C - show solution

∫₋₁¹ 3x² dx = [x³]₋₁¹ = 2. ∫₋₁¹ ax dx = 0 because x is odd over a symmetric interval. ∫₋₁¹ 1 dx = 2. So I(a) = 4 for every a. It is independent of a and always positive, never negative. Answer: (A) and (C).

Concept: Odd functions integrate to zero over symmetric limits, removing the a-dependence. The trap is assuming a parameter in the integrand must affect the value.

Q28MSQ1 mark · no negative· Easy

In a system, numbers are represented using 4-bit two's complement form. Consider four numbers N1 = 1011, N2 = 1101, N3 = 1010 and N4 = 1001 in the system. Which of the following operations will result in arithmetic overflow?

  1. (A)N1 + N2
  2. (B)N2 + N3
  3. (C)N3 - N4
  4. (D)N1 + N4
Answer: B, D - show solution

Values: N1 = -5, N2 = -3, N3 = -6, N4 = -7. Range is -8 to 7. N1 + N2 = -8: fits. N2 + N3 = -9: overflow. N3 - N4 = -6 + 7 = 1: fits. N1 + N4 = -12: overflow. Answer: (B) and (D).

Concept: Overflow occurs when the true result lies outside [-8, 7]; adding two negatives can overflow, subtracting a negative from a negative cannot here. The trap is forgetting -8 is representable, so N1 + N2 is fine.

Q29MSQ1 mark · no negative· Easy

Which of the following grammars is/are ambiguous?

  1. (A)S → aSb | ε
  2. (B)E → E + E | E * E | id
  3. (C)S → aS | Sa | ε
  4. (D)S → aS | ε
Answer: B, C - show solution

(A) generates aⁿbⁿ with exactly one derivation per string. (B) id + id * id has two parse trees (+ at root or * at root): ambiguous. (C) 'a' can be derived as S → aS → a or S → Sa → a: two parse trees, ambiguous. (D) is right-linear with one derivation per aⁿ. Answer: (B) and (C).

Concept: Ambiguity means some string has two distinct parse trees. Grammars that can grow on both sides from the same nonterminal (like C) or lack precedence (B) are typical. The trap is thinking C is safe because its language a* is simple.

Q30NAT1 mark · no negative· Easy

The keys 5, 28, 19, 15, 26, 33, 12, 17, 10 are inserted into a hash table using the hash function h(k) = k mod 9. The collisions are resolved by chaining. After all the keys are inserted, the length of the longest chain is __________. (answer in integer)

Answer: 3 - show solution

k mod 9: 5→5, 28→1, 19→1, 15→6, 26→8, 33→6, 12→3, 17→8, 10→1. Slot 1 holds 28, 19, 10 (3 keys); slots 6 and 8 hold 2 each; others at most 1. Longest chain = 3. Answer: 3.

Concept: Separate chaining: just compute each bucket and count. The usual slip is an arithmetic error in a mod computation.

Q31NAT1 mark · no negative· Easy

Consider the system of linear equations given below. ax + y = b 16x + ay = 24 Suppose the values of a and b are chosen such that the system of linear equations produce multiple solutions. Then the product of a and b is __________. (answer in integer)

Answer: 24 - show solution

Infinitely many solutions require the two equations to be proportional: a/16 = 1/a = b/24. From a/16 = 1/a, a² = 16, a = ±4. Then b = 24/a: a = 4 gives b = 6, a = -4 gives b = -6. Either way ab = 24. Answer: 24.

Concept: Two lines coincide when coefficient ratios and constant ratio are all equal. The trap is setting only the determinant to zero (that also allows no solution) and forgetting the constant ratio.

Q32NAT1 mark · no negative· Moderate

Consider an array A = [10, 7, 8, 19, 41, 35, 25, 31]. Suppose the merge sort algorithm is executed on array A to sort it in increasing order. The merge sort algorithm will carry out a total of 7 merge operations. A merge operation on sorted left array L and sorted right array R is said to be void if the output of the merge operation is the elements of array L followed by the elements of array R. The number of void merge operations among these 7 merge operations is __________. (answer in integer)

Answer: 3 - show solution

Level 1: [10]+[7] not void; [8]+[19] void; [41]+[35] not void; [25]+[31] void. Level 2: [7,10]+[8,19] not void (8 < 10); [35,41]+[25,31] not void. Level 3: [7,8,10,19]+[25,31,35,41] void (19 < 25). A merge is void exactly when max(L) < min(R). Total = 3. Answer: 3.

Concept: Trace top-down merge sort level by level; a merge is void when the largest element of L is below the smallest of R. The trap is checking the original unsorted halves instead of the sorted subarrays.

Q33NAT1 mark · no negative· Easy

If an IP network uses a subnet mask of 255.255.240.0, the maximum number of IP addresses that can be assigned to network interfaces is __________. (answer in integer)

Answer: 4094 - show solution

255.255.240.0 = 11111111.11111111.11110000.00000000, a /20 mask, leaving 32 - 20 = 12 host bits. That gives 2¹² = 4096 addresses; excluding the network address (all host bits 0) and the broadcast address (all 1) leaves 4094 assignable. Answer: 4094.

Concept: Usable hosts = 2^(host bits) - 2. The trap is answering 4096 by forgetting the network and broadcast addresses, or miscounting the bits in 240 (four 1s).

Q34NAT1 mark · no negative· Easy

The 32-bit IEEE 754 single precision representation of a number is 0xC2710000. The number in decimal representation is ________. (rounded off to two decimal places)

Answer: -60.25 - show solution

0xC2710000 = 1 10000100 11100010000000000000000. Sign = 1 (negative). Exponent = 10000100₂ = 132, unbiased 132 - 127 = 5. Significand = 1.1110001₂. Value = -1.1110001₂ x 2⁵ = -111100.01₂ = -(32 + 16 + 8 + 4 + 0.25) = -60.25. Answer: -60.25.

Concept: IEEE 754 decoding: 1 sign bit, 8-bit exponent with bias 127, implicit leading 1. Traps: forgetting the hidden 1, using bias 128, or misaligning the hex nibbles across the sign/exponent boundary.

Q35NAT1 mark · no negative· Moderate

A lexical analyzer uses the following token definitions letter → [A-Za-z] digit → [0-9] id → letter (letter | digit)* number → digit⁺ ws → (blank | tab | newline)⁺ For the string given below, x1 23mm 78 y 7z zz5 14A 8H AaYcD the number of tokens (excluding ws) that will be produced by the lexical analyzer is __________. (answer in integer)

Answer: 13 - show solution

Use longest match. x1 → id (1). 23mm → number 23, id mm (2). 78 → number (1). y → id (1). 7z → number 7, id z (2). zz5 → id (1). 14A → number 14, id A (2). 8H → number 8, id H (2). AaYcD → id (1). Total = 1+2+1+1+2+1+2+2+1 = 13. Answer: 13.

Concept: An id must start with a letter, so a word beginning with digits splits into a number followed by an id. The trap is counting each blank-separated word as one token (giving 9).

Q36MCQ2 marks · -2/3· Moderate

Consider a complete graph Kₙ with n vertices (n > 4). Note that multiple spanning trees can be constructed over Kₙ. Each of these spanning trees is represented as a set of edges. The Jaccard coefficient between any two sets is defined as the ratio of the size of the intersection of the two sets to the size of the union of the two sets. Which one of the following options gives the lowest possible value for the Jaccard coefficient between any two spanning trees of Kₙ?

  1. (A)1/n
  2. (B)1/(2n - 3)
  3. (C)0
  4. (D)1/(n - 1)
Answer: C - show solution

The coefficient is 0 exactly when two spanning trees share no edge. Kₙ has n(n-1)/2 edges, and for n ≥ 4 it contains two edge-disjoint spanning trees (Nash-Williams; indeed Kₙ decomposes into floor(n/2) of them). Example for n = 5: T1 = path 1-2-3-4-5 = {12, 23, 34, 45} and T2 = path 1-3-5-2-4 = {13, 35, 25, 24}, which share no edge. So the minimum is 0. Answer: (C) 0.

Concept: Edge-disjoint spanning trees exist in dense graphs; Kₙ has enough edges (at least 2(n-1) for n ≥ 4). The trap is assuming all spanning trees must share some edge and computing 1/(2n-3), which is the value for exactly one shared edge.

Q37MCQ2 marks · -2/3· Easy

Let G be a weighted directed acyclic graph with m edges and n vertices. Given G and a source vertex s in G, which one of the following options gives the worst case time complexity of the fastest algorithm to find the lengths of shortest paths from s to all vertices that are reachable from s in G?

  1. (A)Θ(m + n)
  2. (B)Θ(m + n log(n))
  3. (C)Θ(nm)
  4. (D)Θ(n³)
Answer: A - show solution

Topologically sort the DAG in Θ(m + n), then relax the outgoing edges of each vertex in topological order. Every edge is relaxed once, and when a vertex is processed its distance is final. Total Θ(m + n), and every edge may need to be examined, so this is optimal. It also handles negative weights. Answer: (A).

Concept: DAG shortest paths need no priority queue. The trap is reaching for Dijkstra (B) or Bellman-Ford (C) without exploiting acyclicity.

Q38MCQ2 marks · -2/3· Moderate

Consider an array A of integers of size n. The indices of A run from 1 to n. An algorithm is to be designed to check whether A satisfies the condition given below. ∀ i, j ∈ {1, ..., n - 1} such that i > j, (A[i + 1] - A[i]) > (A[j + 1] - A[j]) Which one of the following gives the worst case time complexity of the fastest algorithm that can be designed for the problem?

  1. (A)Θ(n)
  2. (B)Θ(log(n))
  3. (C)Θ(n log(n))
  4. (D)Θ(n²)
Answer: A - show solution

Let dᵢ = A[i+1] - A[i] for i = 1..n-1. The condition says dᵢ > dⱼ whenever i > j, i.e. the difference sequence is strictly increasing. By transitivity it suffices to check dᵢ₊₁ > dᵢ for consecutive i: one pass, Θ(n). A lower bound of Ω(n) holds because any unread element could break the condition. Answer: (A) Θ(n).

Concept: A condition over all pairs often reduces to adjacent pairs via transitivity. The trap is checking all pairs in Θ(n²) or thinking binary search applies.

Q39MCQ2 marks · -2/3· Moderate

Consider a table T, where the elements T[i][j], 0 ≤ i, j ≤ n, represent the cost of the optimal solutions of different subproblems of a problem that is being solved using a dynamic programming algorithm. The recursive formulation to compute the table entries is as follows: T[0][k] = T[k][0] = 1 for k = 0, 1, 2, ..., n T[i][j] = 2T[i-1][j] + 3T[i][j-1] for 1 ≤ i, j ≤ n Consider the following two algorithms to compute entries of T. Assume that for both the algorithms, for all 0 ≤ i, j ≤ n, T[i][j] has been initialized to 1. Algorithm B1: For i = 1, 2, ..., n For j = 1, 2, ..., n T[i][j] = 2T[i-1][j] + 3T[i][j-1] Algorithm B2: For s = 2, 3, ..., 2n For i = 1, 2, ..., n For j = 1, 2, ..., n If (i + j == s) T[i][j] = 2T[i-1][j] + 3T[i][j-1] Algorithm Bk, k ∈ {1,2} is said to be correct if and only if it calculates the correct values of T[i][j], for all 0 ≤ i, j ≤ n, (as per the recursive formulation) at the end of the execution of the algorithm Bk. Which one of the following statements is true?

  1. (A)Both algorithms B1 and B2 are correct
  2. (B)Algorithm B1 is correct, but algorithm B2 is incorrect
  3. (C)Algorithm B2 is correct, but algorithm B1 is incorrect
  4. (D)Both algorithms B1 and B2 are incorrect
Answer: A - show solution

T[i][j] depends on T[i-1][j] (row above) and T[i][j-1] (left). Boundary entries are already 1. B1 fills row by row, left to right, so both dependencies are final when used: correct. B2 fills anti-diagonals i + j = s in increasing s; both dependencies lie on diagonal s - 1 (or on the boundary), already computed: correct. B2 is just slower (Θ(n³)). Answer: (A).

Concept: A DP evaluation order is valid if every entry's dependencies are computed before it. Both row-major and anti-diagonal orders satisfy this. The trap is judging B2 wrong because of its wasted iterations.

Q40MCQ2 marks · -2/3· Easy

Consider the following 4-variable Boolean function F(A, B, C, D) = Σm(0, 1, 2, 3, 8, 9, 10, 11) Consider A as MSB, D as LSB. Which one of the following options represents the minimal sum of products form for the above function? Note: + is OR operation, . is AND operation, ' is NOT operation

  1. (A)A' + B' + C' + D'
  2. (B)B'
  3. (C)A'.B' + A.B
  4. (D)A'
Answer: B - show solution

Minterms 0-3 are 00xx (A'B') and minterms 8-11 are 10xx (AB'). Together they are all minterms with B = 0 regardless of A, C, D: F = A'B' + AB' = B'. Answer: (B) B'.

Concept: Group the eight 1-cells in a K-map; an octet eliminates three variables. The trap is (C), which replaces AB' with AB.

Q41MCQ2 marks · -2/3· Hard

Consider the canonical LR(0) parsing of the grammar below using terminals {a, b, c} and non-terminals {A, B, C, S} with S as the start symbol. S → ACB A → aA | ε C → cC | ε B → bB | b Which one of the following options gives the number of shift-reduce conflicts that will occur in the LR(0) ACTION table?

  1. (A)2
  2. (B)3
  3. (C)4
  4. (D)5
Answer: D - show solution

Augment with S' → S. I0 = {S' → .S, S → .ACB, A → .aA, A → .}: shift on a and reduce A → ε (LR(0) reduces in every column) - conflict 1. I(a) = {A → a.A, A → .aA, A → .}: shift a vs reduce - conflict 2. I(A) = {S → A.CB, C → .cC, C → .}: shift c vs reduce - conflict 3. I(c) = {C → c.C, C → .cC, C → .}: conflict 4. I(AC) = {S → AC.B, B → .bB, B → .b}: shifts only. I(b) = {B → b.B, B → b., B → .bB, B → .b}: shift b vs reduce B → b - conflict 5. Other states have no conflict. Total = 5. Answer: (D) 5.

Concept: In LR(0), a state with a completed item reduces on every terminal, so any shift in that state conflicts. ε-productions create a completed item in every state that predicts them. The trap is missing the B → b. state or forgetting I0.

Q42MCQ2 marks · -2/3· Moderate

In the context of schema normalization in relational DBMS, consider a set F of functional dependencies. The set of all functional dependencies implied by F is called the closure of F. To compute the closure of F, Armstrong's Axioms can be applied. Consider X, Y, and Z as sets of attributes over a relational schema. The three rules of Armstrong's Axioms are described as follows. Reflexivity: If Y ⊆ X, then X → Y Augmentation: If X → Y, then XZ → YZ for any Z Transitivity: If X → Y and Y → Z, then X → Z The additional rule of Union is defined as follows. Union: If X → Y and X → Z, then X → YZ It can be proved that the additional rule of Union is also implied by the three rules of Armstrong's Axioms. Listed below are four combinations of these three rules. Which one of these combinations is both necessary and sufficient for the proof?

  1. (A)Reflexivity, Augmentation, and Transitivity
  2. (B)Reflexivity and Augmentation
  3. (C)Transitivity
  4. (D)Augmentation and Transitivity
Answer: D - show solution

Augment X → Y with X: X → XY (since XX = X). Augment X → Z with Y: XY → YZ. Transitivity on X → XY and XY → YZ gives X → YZ. Only augmentation and transitivity are used, and neither alone suffices (transitivity cannot combine right-hand sides; augmentation cannot chain). Answer: (D).

Concept: The standard derivation of the union rule. The trap is (A): all three axioms are sufficient but reflexivity is not necessary.

Q43MCQ2 marks · -2/3· Easy

Consider the transmission of data bits 110001011 over a link that uses Cyclic Redundancy Check (CRC) code for error detection. If the generator bit pattern is given to be 1001, which one of the following options shows the remainder bit pattern appended to the data bits before transmission?

  1. (A)011
  2. (B)101
  3. (C)000
  4. (D)100
Answer: D - show solution

Generator 1001 has degree 3, so append three 0s: 110001011000. Modulo-2 division by 1001: 1100 xor 1001 = 0101; continue bringing down bits and XORing whenever the leading bit is 1. Working through the 12 bits leaves remainder 100. The transmitted frame is 110001011100. Answer: (D) 100.

Concept: CRC: append (degree of generator) zeros, divide with XOR (no borrows), the remainder is the checksum. Traps: appending 4 zeros instead of 3, or doing ordinary subtraction.

Q44MCQ2 marks · -2/3· Moderate

Consider a processor that has 16 general purpose registers and it uses 2-byte instruction format for all its instructions. Variable-sized opcodes are permitted. There are three different types of instructions; M-type, R-type, and C-type. Each M-type instruction has 2 register operands and a 6-bit immediate operand. Each R-type instruction has 3 register operands. Each C-type instruction has a register operand and a 6-bit offset value. If there are 2 unique M-type opcodes and 7 unique R-type opcodes, which one of the following options gives the maximum number of unique opcodes possible for C-type instructions?

  1. (A)8
  2. (B)4
  3. (C)64
  4. (D)16
Answer: B - show solution

Instruction = 16 bits, register field = 4 bits. M-type: 4+4+6 = 14 operand bits, 2-bit opcode. R-type: 12 operand bits, 4-bit opcode. C-type: 4+6 = 10 operand bits, 6-bit opcode. Expanding opcodes: 2² = 4 codes, M uses 2, leaving 2. Each extends by 2 bits: 2 x 4 = 8 R-level codes; R uses 7, leaving 1. That extends by 2 more bits: 1 x 4 = 4 C-type opcodes. Answer: (B) 4.

Concept: Expanding-opcode technique: unused shorter opcodes become prefixes for longer ones. The trap is answering 64 by giving C-type the full 6-bit opcode space.

Q45MCQ2 marks · -2/3· Moderate

Consider the control flow graph given below. ENTRY → B1 B1: a = b + c (successors: B2, B3) B2: d = a + e (successor: B4) B3: e = a + f (successor: B1) B4: g = d + e (successor: EXIT) Which one of the following options is the set of live variables at the exit point of each basic block?

  1. (A)B1:{a, b, c, e, f}, B2:{d, e}, B3:{b, c, e, f}, B4:∅
  2. (B)B1:∅, B2:{d, e}, B3:{a, c, f}, B4:∅
  3. (C)B1:{a, b, c, e, f}, B2:{d, e}, B3:{c, e, f}, B4:∅
  4. (D)B1:∅, B2:{d, e, f}, B3:{a, b, c, e, f}, B4:∅
Answer: A - show solution

in(B) = use(B) ∪ (out(B) - def(B)), out(B) = union of in(successors). B4: out = ∅, in = {d, e}. B2: out = {d, e}, in = {a, e}. B3: in = {a, f} ∪ (out(B3) - {e}), out(B3) = in(B1). B1: in = {b, c} ∪ (out(B1) - {a}), out(B1) = in(B2) ∪ in(B3). Iterate to a fixed point: out(B1) = {a, e} ∪ {a, f, b, c} = {a, b, c, e, f}; in(B1) = {b, c, e, f}; out(B3) = {b, c, e, f}. Answer: (A).

Concept: Backward dataflow analysis with a loop (B3 → B1) needs iteration until nothing changes. The trap is stopping after one pass and missing that e and f flow around the loop, or that e is killed in B3 but live again from B1.

Q46MCQ2 marks · -2/3· Moderate

An index in a DBMS is said to be dense if an index entry appears for every search-key value in the indexed file. Otherwise it is called a sparse index. Consider the following two statements. S1: A hash index must be a dense index S2: A B+ tree index can be a sparse index Which one of the following options is correct?

  1. (A)Both S1 and S2 are true
  2. (B)Both S1 and S2 are false
  3. (C)S1 is true and S2 is false
  4. (D)S1 is false and S2 is true
Answer: A - show solution

S1: A hash index locates a record by hashing its exact key value; there is no ordering to let one entry cover a range of keys, so every search-key value must have an entry - it is a secondary-style dense index. True. S2: On a file sorted by the search key, a B+ tree can store one entry per data block (leaf entries point to blocks), which is a sparse index. True. Answer: (A).

Concept: Sparse indexing works only when the file is ordered on the key, so the index can point to the block where a key would lie. Hashing has no such order. The trap is assuming B+ trees must always be dense.

Q48MSQ2 marks · no negative· Moderate

Let Σ = {a, b, c, d} and let L = {aⁱ bʲ cᵏ dˡ | i, j, k, l ≥ 0}. Which of the following constraints ensure(s) that the language L is context-free?

  1. (A)i + k = j + l
  2. (B)i = k and j = l
  3. (C)i = l and j = k
  4. (D)i + j = k + l
Answer: A, C, D - show solution

(A) i - j + k - l = 0: a PDA keeps a signed counter on the stack (+1 for a, c; -1 for b, d), using a marker for sign; accept when it returns to zero. Context-free. (B) i = k and j = l are crossing dependencies (like aⁱbʲcⁱdʲ), not context-free by the pumping lemma. (C) i = l, j = k is nested: S → aSd | T, T → bTc | ε. Context-free. (D) i + j = k + l: push for a and b, pop for c and d. Context-free. Answer: (A), (C) and (D).

Concept: A single stack handles nested or counter-style constraints but not two interleaved (crossing) equalities. The trap is (A), which looks crossing but is really one balanced counter.

Q49MSQ2 marks · no negative· Hard

Consider a binary search tree (BST) with n leaf nodes (n > 0). Given any node V, the key present in the node is denoted as Val(V). All the keys present in the given BST are distinct. The keys belong to the set of real numbers. For a node V, let Suc(V) denote the node that is its inorder successor. If a node V does not have an inorder successor, then Suc(V) is NULL. As there are no duplicates, if Suc(V) is not NULL, then Val(V) < Val(Suc(V)). Corresponding to every leaf node Lᵢ that has a non-NULL Suc(Lᵢ), a new key kᵢ with the following property is to be inserted into the BST. Val(Lᵢ) < kᵢ < Val(Suc(Lᵢ)) Let K represent the list of all such new keys to be inserted into the BST. Which of the following statements is/are true?

  1. (A)K cannot have any duplicates
  2. (B)K will have at least one element
  3. (C)After inserting all keys from K, the height of the BST can increase at most by one
  4. (D)Number of nodes in the BST will double after inserting all keys from K
Answer: A, C - show solution

(A) Each interval (Val(Lᵢ), Val(Suc(Lᵢ))) lies between consecutive keys in sorted order, so different leaves give disjoint open intervals: no duplicates. True. (B) If the only leaf holds the maximum key (e.g. a single-node tree or a right-skewed chain), it has no successor and K is empty. False. (C) A leaf has no right child, and kᵢ lies just after Val(Lᵢ) in order, so kᵢ is inserted as the right child of Lᵢ. Each new node hangs one level below an old leaf, so height grows by at most one. True. (D) Only leaves get new keys, so nodes do not double in general. False. Answer: (A) and (C).

Concept: A key between a node and its inorder successor is inserted as that node's right child if it has none. The trap is (B): the single-leaf case can have no successor.

Q50MSQ2 marks · no negative· Moderate

Consider a stack S and a queue Q. Both of them are initially empty and have the capacity to store ten elements each. The elements 1, 2, 3, 4, and 5 arrive one by one, in that order. When an element arrives, it is assigned either to S (pushed on S) or to Q (enqueued to Q). Once all the five elements are stored, the output is generated in two steps. First, stack S is emptied by popping all elements. Then queue Q is emptied by dequeueing all elements. The output obtained by following this process is 4 3 1 2 5. Given the output, the objective is to predict whether an element was assigned to S or Q. Which of the following options is/are possible valid assignment(s) of the elements? Note: In the options, the notation xS denotes that element x was assigned to S and yQ denotes that element y was assigned to Q.

  1. (A)1S, 2Q, 3S, 4S, 5Q
  2. (B)1Q, 2Q, 3S, 4S, 5Q
  3. (C)1Q, 2Q, 3Q, 4S, 5S
  4. (D)1S, 2S, 3S, 4Q, 5Q
Answer: A, B - show solution

Stack output is its elements in decreasing arrival order, then the queue in increasing order. (A) S = {1,3,4} → 4 3 1, Q = {2,5} → 2 5: output 4 3 1 2 5. Valid. (B) S = {3,4} → 4 3, Q = {1,2,5} → 1 2 5: 4 3 1 2 5. Valid. (C) S = {4,5} → 5 4 first. Invalid. (D) S = {1,2,3} → 3 2 1 first. Invalid. Answer: (A) and (B).

Concept: Simulate each assignment. The output can be split as a decreasing prefix (stack) and an increasing suffix (queue); element 1 can sit on either side of the split, giving two valid answers.

Q51MSQ2 marks · no negative· Moderate

Consider three processes P1, P2, and P3 running identical code, as shown in the pseudocode below. A and B are two binary semaphores initialized to 1 and 0, respectively. X is a shared variable initialized to 0. Each line in the pseudocode is executed atomically. Assume that any of the three processes can start to execute first and context switching can happen between these processes at any arbitrary time and in any arbitrary order. Which of the following patterns is/are possible to be generated as an outcome of the execution of these three processes?

Wait(A);
Print(*);
X = X+1;
If (X == 2)
   {
      Print($);
      Signal(B);
   }
Signal(A);
Wait(B);
Print(#);
Signal(B);
  1. (A)**$*###
  2. (B)**$#*##
  3. (C)**$##*#
  4. (D)***$###
Answer: A, B, C - show solution

The block from Wait(A) to Signal(A) is a critical section. The second process to enter prints * then $ and signals B before releasing A. So $ immediately follows the second *, and the third * can only come after $ - (D) is impossible. After $, B = 1 and each # is followed by Signal(B), so #s chain. (A): third process enters before any #: **$*###. (B): first waiter prints #, then third enters: **$#*##. (C): two #s, then third enters, then its #: **$##*#. All feasible. Answer: (A), (B) and (C).

Concept: Mutual exclusion on A forces * $ of the second process to be adjacent; B acts as a turnstile once opened. The trap is (D), which needs a third * inside another process's critical section.

Q52MSQ2 marks · no negative· Moderate

Consider a system with a processor and a 4 KB direct mapped cache with block size of 16 bytes. The system has a 16 MB physical memory. Four words P, Q, R, and S are accessed by the processor in the same order 10 times. That is, there are a total of 40 memory references in the sequence P, Q, R, S, P, Q, R, S, ... Assume that the cache memory is initially empty. The physical addresses of the words are given below (1 word = 1 byte). P: 0x845B32, Q: 0x845B26, R: 0x845B36, S: 0x846B32 Which of the following statements is/are true? Note: 1K = 2¹⁰ and 1M = 2²⁰

  1. (A)Every access to P results in a cache miss
  2. (B)Every access to R results in a cache hit
  3. (C)Every access to Q results in a cache miss
  4. (D)Except the first access to S, all subsequent accesses to S result in cache hits
Answer: A, B - show solution

24-bit address; 256 lines, so offset 4 bits, index 8 bits, tag 12 bits. P: tag 845, index B3. Q: tag 845, index B2. R: tag 845, index B3 (same block as P). S: tag 846, index B3. Each round: P misses (S evicted it, or cold), Q hits after the first round (own line B2), R hits (block just loaded by P), S misses and evicts P's block. So P always misses, R always hits, Q misses only once, S always misses. Answer: (A) and (B).

Concept: Split addresses into tag/index/offset; words in the same block share a line, and different tags on the same index thrash. The trap is thinking R misses because it differs from P - it is in the same 16-byte block.

Q53NAT2 marks · no negative· Moderate

To keep track of free blocks in a file system, one of the two approaches is generally used - using bitmaps (bit vectors) or using linked lists. Consider that the linked list approach is used to keep track of free blocks in a file system. Assume that the disk size is 16 GB, block size is 2 KB, and block numbers used are 32-bit long. A single pointer of size 4 bytes is used in each block of the list to point to the next block of the list. The number of blocks required to hold the free disk block numbers is ____________. (answer in integer) Note: 1K = 2¹⁰ and 1G = 2³⁰

Answer: 16417 - show solution

Number of disk blocks = 16 GB / 2 KB = 2³⁴ / 2¹¹ = 2²³ = 8,388,608. Each list block holds (2048 - 4)/4 = 511 block numbers (4 bytes reserved for the next pointer). In the worst case (all blocks free) the list needs ceil(8,388,608 / 511) = ceil(16416.06) = 16417 blocks. Answer: 16417.

Concept: Grouped free-list sizing: subtract the next-pointer from each block's capacity and take the ceiling. Traps: using 512 entries per block (giving 16384) or forgetting to round up.

Q54NAT2 marks · no negative· Moderate

A system has a Translation Lookaside Buffer (TLB) that has a reach of 1 MB. TLB reach is defined as the total amount of physical memory that can be accessed through the TLB entries. The paging system uses pages of size 4 KB. The virtual address space is 64 GB and physical address space is 1 GB. If each TLB entry stores a 4-bit process id, page number, frame number, and a 2-bit control field, then the size of the TLB (in bytes) is ___________. (answer in integer) Note: 1K = 2¹⁰, 1M = 2²⁰, 1G = 2³⁰

Answer: 1536 - show solution

Entries = reach / page size = 2²⁰ / 2¹² = 256. Page number bits = log₂(64 GB / 4 KB) = 36 - 12 = 24. Frame number bits = log₂(1 GB / 4 KB) = 30 - 12 = 18. Entry = 4 + 24 + 18 + 2 = 48 bits = 6 bytes. TLB size = 256 x 6 = 1536 bytes. Answer: 1536.

Concept: TLB reach = entries x page size, giving the entry count; each entry stores the full virtual page number (fully associative) plus frame number and extras. The trap is using the address widths (36, 30) instead of page/frame number widths.

Q55NAT2 marks · no negative· Easy

Consider contiguous allocation of physical memory to processes using variable partitioning scheme. Suppose there are 8 holes in the memory of sizes 20 KB, 4 KB, 25 KB, 18 KB, 7 KB, 9 KB, 15 KB, and 12 KB. Assume that no two holes are adjacent. Two processes P1 of size 16 KB and P2 of size 9 KB arrive in that order, and they are allocated memory using the best-fit technique. After allocating space to P1 and P2, the number of holes of size less than 8 KB is ____________. (answer in integer) Note: 1K = 2¹⁰

Answer: 3 - show solution

Best fit for P1 (16 KB): smallest hole ≥ 16 is 18 KB, leaving a 2 KB hole. Best fit for P2 (9 KB): the 9 KB hole fits exactly, leaving no hole. Holes now: 20, 4, 25, 2, 7, 15, 12. Those below 8 KB: 4, 2, 7 = 3. Answer: 3.

Concept: Best fit picks the smallest adequate hole and tends to leave tiny fragments. The trap is counting a 0 KB leftover as a hole.

Q56NAT2 marks · no negative· Hard

Consider a system with 1 MB physical memory and a word length of 1 byte. The system uses a direct mapped cache, with block numbers starting from 0. The word with physical address 0xA2C28 is mapped to the cache block number 176 (decimal). The maximum possible size of the cache (in KB) for this configuration is ___________. (answer in integer) Note: 1K = 2¹⁰ and 1M = 2²⁰

Answer: 128 - show solution

Address is 20 bits: 0xA2C28 = 1010 0010 1100 0010 1000. The index field is a contiguous bit range just above the offset whose value must be 176 = 10110000₂. The pattern 10110000 occurs at bits 13..6 (counting bit 0 as LSB), so the offset is bits 5..0 (block size 64 bytes). Leading zeros extend the index upward: bits 16, 15, 14 are 0, bit 17 is 1. So the index can be bits 16..6 = 11 bits, value 00010110000₂ = 176. Cache size = 2¹¹ blocks x 64 B = 128 KB. Answer: 128.

Concept: Index bits of the address must equal the block number; the cache is largest when the index is widened with leading zeros as far as possible. The trap is assuming a fixed block size or ignoring that leading zeros may join the index.

Q57NAT2 marks · no negative· Easy

A non-pipelined instruction execution unit that operates at 1.6 GHz clock takes an average of 5 clock cycles to complete the execution of an instruction. To improve the performance, the system was pipelined with a goal of achieving an average throughput of one instruction per clock cycle. However, it could operate only at 1.2 GHz due to pipeline overheads. While executing a program in the pipelined design, 30% of instructions encountered a stall of 2 cycles due to pipeline hazards. The speed-up obtained by the pipelined design over the non-pipelined one for this program is ___________. (rounded off to two decimal places) Note: 1G = 10⁹

Answer: 2.3 to 2.4 - show solution

Non-pipelined time per instruction = 5 / 1.6 GHz = 3.125 ns. Pipelined CPI = 1 + 0.3 x 2 = 1.6, time = 1.6 / 1.2 GHz = 1.333 ns. Speed-up = 3.125 / 1.333 = 2.34. Answer: 2.34 (accepted range 2.3 to 2.4).

Concept: Speed-up compares execution time per instruction (CPI x cycle time), so the slower pipelined clock must be included. Traps: using 5/1.6 cycles ratio alone (3.125) or ignoring stalls (3.75).

Q58NAT2 marks · no negative· Moderate

Consider a new TCP connection between a sender and a receiver. The receiver advertised window is constant at 48 KB, the maximum segment size (MSS) is 2 KB, and the slow start threshold for TCP congestion control is 16 KB. Assume that there are no timeouts or duplicate acknowledgements. The number of rounds of transmission required for the congestion control algorithm of the TCP connection to reach the congestion avoidance phase is ___________. (answer in integer) Note: 1K = 2¹⁰

Answer: 4 - show solution

Slow start begins at cwnd = 1 MSS = 2 KB and doubles each round: round 1: 2 KB, round 2: 4 KB, round 3: 8 KB, round 4: 16 KB. In round 4 cwnd reaches ssthresh = 16 KB (8 MSS), so the connection is now in congestion avoidance and grows linearly afterwards. The 48 KB receiver window never limits this. Answer: 4.

Concept: Slow start doubles cwnd per RTT until it reaches ssthresh, then switches to additive increase. The trap is starting cwnd at 0 or counting the number of doublings (3) rather than transmission rounds.

Q59NAT2 marks · no negative· Easy

Consider the digital circuit described below with two input lines A and B, two select lines S0 and S1, and an output line Y. The blocks Q and M represent an active high 2:4 decoder and a 4-to-1 multiplexer, respectively. A and B are the inputs of decoder Q (A is the MSB), with outputs D0, D1, D2, D3. The multiplexer M has select lines S1 S0 and data inputs: input 0 = D0, input 1 = constant 0, input 2 = constant 1, input 3 = D3. M's output is Y. (D1 and D2 are unused.) Out of 16 possible input combinations, the number of combinations that produce Y=1 is ____________. (answer in integer) Note: One input combination is an instance of [A B S1 S0].

Answer: 6 - show solution

D0 = A'B', D3 = AB. S1S0 = 00: Y = D0, true for AB = 00 only: 1 combination. S1S0 = 01: Y = 0: 0. S1S0 = 10: Y = 1 for all four AB: 4. S1S0 = 11: Y = D3, true for AB = 11: 1. Total = 1 + 0 + 4 + 1 = 6. Answer: 6.

Concept: Enumerate by select-line value: each mux input contributes the number of AB values that make it 1. The trap is counting only distinct select values, or treating the decoder outputs as active low.

Q60NAT2 marks · no negative· Easy

Consider the following ANSI-C program. The output of this program is ____________. (answer in integer) Note: Assume that the program compiles and runs successfully.

#include <stdio.h>

int main(){
      int *ptr, a, b, c;
      a=5; b=11; c=20;
      ptr=&a; *ptr=c; ptr=&c;
      a=*(&b); c=*ptr-a;
      printf("%d",c);
      return(0);
}
Answer: 9 - show solution

a=5, b=11, c=20. ptr=&a; *ptr=c sets a=20. ptr=&c. a=*(&b) sets a=11. c=*ptr-a = c - a = 20 - 11 = 9. Output: 9.

Concept: Track which variable ptr points to after each assignment; *(&b) is simply b. The trap is using the stale value of a or thinking *ptr still refers to a.

Q61NAT2 marks · no negative· Moderate

Consider the following ANSI-C function. The maximum possible value that can be returned from this function is ____________. (answer in integer) Note: Ignore syntax errors (if any) in the function.

int func(int start, int end){
  int length=end+1-start;
  if((length<1)||(start<0)||(end<0)){
    return(0);
  }
  if(length%3==0){
    return(func(start+1, end));
  }
  else if(length%3==1){
    return(1+func(start, end-1));
  }
  else {
    return(func(start+2, end));
  }
}
Answer: 1 - show solution

Only the length%3==1 branch adds 1, and each call reduces length. Track length L mod 3: L ≡ 1 → add 1, L-1 (≡ 0). L ≡ 0 → L-1 (≡ 2). L ≡ 2 → L-2 (≡ 0). From ≡ 0 the chain alternates 0 → 2 → 0 → 2 ... and never returns to ≡ 1, ending at length 0 or -1 which returns 0. So at most one +1 can occur, when the initial length is ≡ 1 mod 3 (e.g. func(0,0) = 1). Maximum = 1. Answer: 1.

Concept: Analyse the recursion as a state machine on length mod 3. The trap is assuming each cycle adds 1 and getting a value growing with n.

Q62NAT2 marks · no negative· Easy

The determinant of a 4 x 4 matrix A is 3. The value of the determinant of 2A is ____________. (answer in integer)

Answer: 48 - show solution

Scaling an n x n matrix by k scales the determinant by kⁿ, since each of the n rows is multiplied by k. det(2A) = 2⁴ x 3 = 16 x 3 = 48. Answer: 48.

Concept: det(kA) = kⁿ det(A). The trap is answering 6 (multiplying once) or 24 (2³).

Q63NAT2 marks · no negative· Moderate

Suppose an unbiased coin is tossed 6 times. Each coin toss is independent of all previous coin tosses. Let E1 be the event that among the second, fourth, and sixth coin tosses, there are at least two heads. Let E2 be the event that among the first, second, third, and fifth coin tosses, there are equal number of heads and tails. The conditional probability P(E1 | E2) is equal to ____________. (rounded off to one decimal place)

Answer: 0.5 - show solution

E2: exactly 2 heads among tosses 1, 2, 3, 5 (6 equally likely patterns). Toss 2 is the only overlap with E1; given E2, toss 2 is H in 3 of 6 patterns, so P(toss2 = H | E2) = 1/2. Tosses 4 and 6 are independent of E2. If toss 2 = H, E1 needs at least one H in tosses 4, 6: 3/4. If toss 2 = T, E1 needs both: 1/4. P(E1 | E2) = 1/2 x 3/4 + 1/2 x 1/4 = 1/2. Answer: 0.5.

Concept: Condition on the single shared toss and use independence for the rest. The trap is treating E1 and E2 as independent without checking, or miscounting the 6 patterns of E2.

Q64NAT2 marks · no negative· Moderate

Consider a function f : (0,1) → {0, 1} defined as follows. For a real number x ∈ (0,1), f(x) = 1 if the second digit after the decimal point in x is one of the four digits 2, 3, 6 and 7. Otherwise, f(x) is equal to 0. The number of points in (0,1) at which f is discontinuous is ___________. (answer in integer)

Answer: 40 - show solution

f is constant on each interval [0.d₁d₂, 0.d₁d₂ + 0.01). Within each tenth, second digits 0-9 give values 0,0,1,1,0,0,1,1,0,0. The value changes at second digits 2 (0→1), 4 (1→0), 6 (0→1) and 8 (1→0): 4 jumps per tenth. Between tenths (second digit 9 to 0) the value stays 0, so no jump. Ten tenths give 4 x 10 = 40 discontinuities, all inside (0,1) (0.02 up to 0.98). Answer: 40.

Concept: A step function is discontinuous only where its value actually changes. The trap is counting every 0.01 boundary (99) or every boundary of an in-set digit block without noticing that 9→0 is not a jump.

Q65NAT2 marks · no negative· Moderate

It is necessary to design a link-layer protocol between two hosts that are directly connected over a lossless link of length 3000 kilometers. Assume that the link bandwidth is 10⁸ bits per second and that the propagation delay in the link is 5 nanoseconds per meter. Every transmitted data byte is assigned a unique sequence number. Let n be the minimum number of bits needed for the sequence number field in the protocol header such that i. the sequence numbers do not wrap around before 60 seconds, and ii. the maximum utilization of the link is achieved. The value of n is ______. (answer in integer)

Answer: 30 - show solution

(i) In 60 s the link carries 10⁸ x 60 = 6 x 10⁹ bits = 7.5 x 10⁸ bytes, each needing a distinct number: 2ⁿ ≥ 7.5 x 10⁸ gives n = 30 (2²⁹ ≈ 5.4 x 10⁸ is too small, 2³⁰ ≈ 1.07 x 10⁹). (ii) One-way delay = 3 x 10⁶ m x 5 ns = 15 ms, RTT = 30 ms; bytes in flight for full utilisation = 10⁸ x 0.03 / 8 = 375,000, needing about 19-20 bits. The binding requirement is (i). n = 30. Answer: 30.

Concept: Sequence space must cover both the wrap-around time and the bandwidth-delay product; take the larger requirement. The trap is computing only the window for utilisation and answering about 19 or 20.

Answers are the official GATE answer key. Questions that depend on a figure are left out until they can be shown faithfully.