Organised by IISc Bengaluru

GATE 2024 CS (Computer Science) Session 1 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

If '→' denotes increasing order of intensity, then the meaning of the words [dry → arid → parched] is analogous to [diet → fast → ________ ]. Which one of the given options is appropriate to fill the blank?

  1. (A)starve
  2. (B)reject
  3. (C)feast
  4. (D)deny
Answer: A - show solution

Dry, arid and parched describe the same idea (lack of water) with rising intensity. Diet means eating less, fast means not eating for a period, and the next, more intense step is to go without food to the point of suffering: starve. Reject, feast and deny do not continue the intensity scale (feast is the opposite). Answer: (A) starve.

Concept: Intensity analogy: the third word must be the strongest form of the same idea. The trap is picking feast because it is food-related, though it reverses the direction.

Q2MCQ1 mark · -1/3· Easy

If two distinct non-zero real variables x and y are such that (x + y) is proportional to (x − y) then the value of x/y

  1. (A)depends on xy
  2. (B)depends only on x and not on y
  3. (C)depends only on y and not on x
  4. (D)is a constant
Answer: D - show solution

Proportionality gives x + y = k(x − y) for a fixed constant k. Then x + y = kx − ky, so y(1 + k) = x(k − 1), hence x/y = (k + 1)/(k − 1). This depends only on the constant k, not on x or y individually. Answer: (D) is a constant.

Concept: Proportionality means a fixed ratio, so solving for x/y removes both variables. The trap is assuming the ratio still varies with x or y.

Q3MCQ1 mark · -1/3· Easy

Consider the following sample of numbers: 9, 18, 11, 14, 15, 17, 10, 69, 11, 13. The median of the sample is

  1. (A)13.5
  2. (B)14
  3. (C)11
  4. (D)18.7
Answer: A - show solution

Sort: 9, 10, 11, 11, 13, 14, 15, 17, 18, 69. There are 10 values, so the median is the mean of the 5th and 6th values: (13 + 14)/2 = 13.5. Answer: (A) 13.5.

Concept: Median of an even-sized sample is the average of the two middle values after sorting. Traps: not sorting first, or computing the mean (18.7), which the outlier 69 inflates.

Q4MCQ1 mark · -1/3· Easy

The number of coins of ₹1, ₹5, and ₹10 denominations that a person has are in the ratio 5:3:13. Of the total amount, the percentage of money in ₹5 coins is

  1. (A)21%
  2. (B)14 2/7%
  3. (C)10%
  4. (D)30%
Answer: C - show solution

Take 5k, 3k and 13k coins. Value: ₹1 coins = 5k, ₹5 coins = 15k, ₹10 coins = 130k. Total = 150k. Share of ₹5 coins = 15k/150k = 10%. Answer: (C) 10%.

Concept: Convert the count ratio to a value ratio before taking percentages. The trap is using the count share 3/21 = 14 2/7%.

Q5MCQ1 mark · -1/3· Easy

For positive non-zero real variables p and q, if log(p² + q²) = log p + log q + 2 log 3, then, the value of (p⁴ + q⁴)/(p²q²) is

  1. (A)79
  2. (B)81
  3. (C)9
  4. (D)83
Answer: A - show solution

The right side is log(9pq), so p² + q² = 9pq. Square: p⁴ + 2p²q² + q⁴ = 81p²q², so p⁴ + q⁴ = 79p²q². Therefore (p⁴ + q⁴)/(p²q²) = 79. Answer: (A) 79.

Concept: Combine logs into one, drop the log, then use (a + b)² = a² + 2ab + b². The trap is answering 81 by forgetting to subtract 2p²q².

Q6MCQ2 marks · -2/3· Moderate

In the given text, the blanks are numbered (i)−(iv). Select the best match for all the blanks. "Steve was advised to keep his head (i) before heading (ii) to bat; for, while he had a head (iii) batting, he could only do so with a cool head (iv) his shoulders."

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

Keep one's head down = stay focused and avoid trouble. A batter heads out to bat. Having a head for something = a natural aptitude for it, so a head for batting. A cool head on one's shoulders = calm and sensible. So (i) down, (ii) out, (iii) for, (iv) on. Answer: (C).

Concept: Tests fixed idioms with prepositions: head down, head out, a head for, a head on one's shoulders. The trap is choosing by sound rather than the fixed phrase.

Q7MCQ2 marks · -2/3· Moderate

A rectangular paper sheet of dimensions 54 cm × 4 cm is taken. The two longer edges of the sheet are joined together to create a cylindrical tube. A cube whose surface area is equal to the area of the sheet is also taken. Then, the ratio of the volume of the cylindrical tube to the volume of the cube is

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

Joining the two 54 cm edges makes a tube of length 54 cm whose circumference is 4 cm, so r = 2/π. Volume = πr²h = π(4/π²)(54) = 216/π. Sheet area = 216 cm², so cube surface 6a² = 216 gives a = 6 and volume 216. Ratio = (216/π)/216 = 1/π. Answer: (A) 1/π.

Concept: When the longer edges are joined, the shorter side becomes the circumference. The trap is using 54 cm as the circumference, which gives a very different radius.

Q8MCQ2 marks · -2/3· Easy

A pie chart presents the percentage contribution of different macronutrients to a typical 2,000 kcal diet of a person: Carbohydrates 35%, Proteins 20%, Unsaturated fat 20%, Saturated fat 20%, Trans fat 5%. The typical energy density (kcal/g) of these macronutrients is given in the table. Macronutrient Energy density (kcal/g) Carbohydrates 4 Proteins 4 Unsaturated fat 9 Saturated fat 9 Trans fat 9 The total fat (all three types), in grams, this person consumes is

  1. (A)44.4
  2. (B)77.8
  3. (C)100
  4. (D)3,600
Answer: C - show solution

Fat share = 20% + 20% + 5% = 45% of 2,000 kcal = 900 kcal. All fats give 9 kcal/g, so mass = 900/9 = 100 g. Answer: (C) 100.

Concept: Convert the energy share to kcal, then divide by energy density to get grams. Traps: using 4 kcal/g, or forgetting trans fat.

Q9MCQ2 marks · -2/3· Moderate

A rectangular paper of 20 cm × 8 cm is folded 3 times. Each fold is made along the line of symmetry, which is perpendicular to its long edge. The perimeter of the final folded sheet (in cm) is

  1. (A)18
  2. (B)24
  3. (C)20
  4. (D)21
Answer: A - show solution

Each fold halves the current long edge. Fold 1: 20 × 8 becomes 10 × 8. Fold 2: long edge 10 becomes 5, giving 5 × 8. Now the long edge is 8, so fold 3 gives 5 × 4. Perimeter = 2(5 + 4) = 18 cm. Answer: (A) 18.

Concept: 'Its long edge' refers to the sheet as it is at each fold, so the folding direction switches once 8 becomes the longer side. The trap is halving 20 three times (2.5 × 8, perimeter 21).

Q11MCQ1 mark · -1/3· Easy

Let f: ℝ → ℝ be a function such that f(x) = max{x, x³}, x ∈ ℝ, where ℝ is the set of all real numbers. The set of all points where f(x) is NOT differentiable is

  1. (A){-1, 1, 2}
  2. (B){-2, -1, 1}
  3. (C){0, 1}
  4. (D){-1, 0, 1} 123
Answer: D - show solution

x³ − x = x(x − 1)(x + 1), so x³ ≥ x on [−1, 0] and [1, ∞), and x ≥ x³ elsewhere. The pieces meet at x = −1, 0, 1. Slopes: at −1, x³ has slope 3 and x has slope 1; at 0, slope 0 vs 1; at 1, slope 1 vs 3. The slopes differ at every crossing, so f has a corner at each. Answer: (D) {−1, 0, 1}.

Concept: A max of two smooth functions can fail to be differentiable only where they cross with different slopes. The trap is forgetting the crossing at x = −1 or 0.

Q12MCQ1 mark · -1/3· Easy

The product of all eigenvalues of the matrix [1 2 3] [4 5 6] [7 8 9] is

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

The product of eigenvalues equals the determinant. Row 3 − Row 2 = Row 2 − Row 1 = (3, 3, 3), so the rows are linearly dependent and the determinant is 0. Answer: (B) 0.

Concept: Product of eigenvalues = determinant; sum = trace. The trap is trying to compute the eigenvalues directly instead of spotting the dependent rows.

Q13MCQ1 mark · -1/3· Easy

Consider a system that uses 5 bits for representing signed integers in 2's complement format. In this system, two integers A and B are represented as A=01010 and B=11010. Which one of the following operations will result in either an arithmetic overflow or an arithmetic underflow?

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

5-bit 2's complement range is −16 to 15. A = 10, B = 11010 = −6. A + B = 4 (fine). A − B = 16 (exceeds 15: overflow). B − A = −16 (representable). 2B = −12 (fine). Answer: (B) A − B.

Concept: Decode both operands, compute in decimal and compare with [−2ⁿ⁻¹, 2ⁿ⁻¹ − 1]. The trap is thinking −16 is out of range; the negative side has one extra value.

Q14MCQ1 mark · -1/3· Easy

Consider a permutation sampled uniformly at random from the set of all permutations of {1, 2, 3, ⋯, n} for some n ≥ 4. Let X be the event that 1 occurs before 2 in the permutation, and Y the event that 3 occurs before 4. Which one of the following statements is TRUE?

  1. (A)The events X and Y are mutually exclusive
  2. (B)The events X and Y are independent
  3. (C)Either event X or Y must occur
  4. (D)Event X is more likely than event Y
Answer: B - show solution

By symmetry P(X) = P(Y) = 1/2. The relative orders of {1, 2} and {3, 4} are independent: of the 4 equally likely combined orderings, exactly one has 1 before 2 and 3 before 4, so P(X ∩ Y) = 1/4 = P(X)P(Y). Hence independent. They can co-occur (not exclusive), both can fail (2 before 1 and 4 before 3), and they are equally likely. Answer: (B).

Concept: Events about disjoint sets of elements in a random permutation are independent. The trap is confusing independent with mutually exclusive.

Q15MCQ1 mark · -1/3· Easy

Which one of the following statements is FALSE?

  1. (A)In the cycle stealing mode of DMA, one word of data is transferred between an I/O device and main memory in a stolen cycle
  2. (B)For bulk data transfer, the burst mode of DMA has a higher throughput than the cycle stealing mode
  3. (C)Programmed I/O mechanism has a better CPU utilization than the interrupt driven I/O mechanism
  4. (D)The CPU can start executing an interrupt service routine faster with vectored interrupts than with non-vectored interrupts
Answer: C - show solution

(A) is true: cycle stealing moves one word per stolen bus cycle. (B) is true: burst mode holds the bus for the whole block, so it has higher throughput. (C) is false: programmed I/O busy-waits on the device, wasting CPU cycles, so interrupt-driven I/O gives better CPU utilization. (D) is true: a vectored interrupt supplies the ISR address directly, avoiding polling. Answer: (C).

Concept: Programmed I/O keeps the CPU polling; interrupts free it until the device is ready. The trap is reading 'programmed' as more efficient.

Q16MCQ1 mark · -1/3· Easy

A user starts browsing a webpage hosted at a remote server. The browser opens a single TCP connection to fetch the entire webpage from the server. The webpage consists of a top-level index page with multiple embedded image objects. Assume that all caches (e.g., DNS cache, browser cache) are all initially empty. The following packets leave the user's computer in some order. (i) HTTP GET request for the index page (ii) DNS request to resolve the web server's name to its IP address (iii) HTTP GET request for an image object (iv) TCP SYN to open a connection to the web server Which one of the following is the CORRECT chronological order (earliest in time to latest) of the packets leaving the computer ?

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

The browser first needs the server's IP, so the DNS request (ii) leaves first. Then TCP opens the connection with SYN (iv). Over that connection it requests the index page (i), and only after parsing it does it learn of and request the embedded image (iii). Order: (ii), (iv), (i), (iii). Answer: (C).

Concept: Name resolution precedes connection setup, which precedes HTTP requests; embedded objects are fetched after the base page. The trap is putting SYN before DNS.

Q17MCQ1 mark · -1/3· Easy

Given an integer array of size N, we want to check if the array is sorted (in either ascending or descending order). An algorithm solves this problem by making a single pass through the array and comparing each element of the array only with its adjacent elements. The worst-case time complexity of this algorithm is

  1. (A)both Ο(N) and Ω(N)
  2. (B)Ο(N) but not Ω(N)
  3. (C)Ω(N) but not Ο(N)
  4. (D)neither Ο(N) nor Ω(N)
Answer: A - show solution

In the worst case (the array is sorted, or the violation is at the end) the single pass makes about N − 1 comparisons, each O(1). So worst-case time is Θ(N), which means it is both O(N) and Ω(N). Answer: (A).

Concept: Θ(N) implies both O(N) and Ω(N). The trap is associating Ω only with best-case analysis; here the bound is on the worst case.

Q18MCQ1 mark · -1/3· Easy

Consider the following C program. Which one of the following statements is CORRECT?

#include <stdio.h>
int main(){
   int a = 6;
   int b = 0;
   while(a < 10) {
      a = a / 12 + 1;
      a += b;}
   printf("%d", a);
   return 0;}
  1. (A)The program prints 9 as output
  2. (B)The program prints 10 as output
  3. (C)The program gets stuck in an infinite loop
  4. (D)The program prints 6 as output
Answer: C - show solution

Start a = 6. Iteration 1: a = 6/12 + 1 = 0 + 1 = 1 (integer division), then a += 0 keeps 1. Next: a = 1/12 + 1 = 1 again. Since b = 0 never changes, a stays 1, which is always < 10, so the loop never exits and nothing is printed. Answer: (C) The program gets stuck in an infinite loop.

Concept: Integer division truncates, and a loop whose variable reaches a fixed point never terminates. The trap is treating 6/12 as 0.5.

Q19MCQ1 mark · -1/3· Easy

Consider the following C program. Assume that the input to the program from the command line is 1234 followed by a newline character. Which one of the following statements is CORRECT?

#include <stdio.h>
void fX();
int main(){
   fX();
   return 0;}

void fX(){
   char a;
   if((a=getchar()) != '\n')
       fX();
   if(a != '\n')
       putchar(a);}
  1. (A)The program will not terminate
  2. (B)The program will terminate with no output
  3. (C)The program will terminate with 4321 as output
  4. (D)The program will terminate with 1234 as output
Answer: C - show solution

Each call reads one character into its own local a and recurses until it reads the newline. Calls hold '1', '2', '3', '4', then a call reads '\n' and returns without printing. As the stack unwinds, each call prints its own character after the deeper call returns: 4, 3, 2, 1. Output 4321 and the program terminates. Answer: (C).

Concept: Printing after the recursive call reverses the input order, since each frame keeps its own local variable. The trap is expecting 1234.

Q21MCQ1 mark · -1/3· Easy

In a B+ tree, the requirement of at least half-full (50%) node occupancy is relaxed for which one of the following cases?

  1. (A)Only the root node
  2. (B)All leaf nodes
  3. (C)All internal nodes
  4. (D)Only the leftmost leaf node
Answer: A - show solution

In a B+ tree every node except the root must be at least half full. The root may hold as few as one key (two children if internal), since it is created and removed as the tree grows and shrinks. Answer: (A) Only the root node.

Concept: The minimum-occupancy rule exempts only the root. The trap is thinking leaves are exempt.

Q22MSQ1 mark · no negative· Easy

Which of the following statements about a relation R in first normal form (1NF) is/are TRUE ?

  1. (A)R can have a multi-attribute key
  2. (B)R cannot have a foreign key
  3. (C)R cannot have a composite attribute
  4. (D)R cannot have more than one candidate key
Answer: A, C - show solution

1NF only requires every attribute to be atomic (single-valued, not composite or multivalued). (A) True: a key may consist of several attributes. (B) False: 1NF says nothing about foreign keys. (C) True: a composite attribute is not atomic. (D) False: any number of candidate keys is allowed. Answer: (A), (C).

Concept: 1NF is purely about atomic values. The trap is reading key-related restrictions into 1NF.

Q23MSQ1 mark · no negative· Moderate

Let L1, L2 be two regular languages and L3 a language which is not regular. Which of the following statements is/are always TRUE?

  1. (A)L1 = L2 if and only if L1 ∩ (complement of L2) = ϕ
  2. (B)L1 ∪ L3 is not regular
  3. (C)The complement of L3 is not regular
  4. (D)(complement of L1) ∪ (complement of L2) is regular
Answer: C, D - show solution

(A) False: L1 ∩ L2' = ϕ only says L1 ⊆ L2; for example L1 = ϕ and L2 = Σ*. (B) False: take L1 = Σ*, then L1 ∪ L3 = Σ*, regular. (C) True: if L3' were regular, L3 = (L3')' would be regular by closure under complement. (D) True: regular languages are closed under complement and union. Answer: (C), (D).

Concept: Use closure properties, and look for counterexamples like Σ* that swallow a non-regular language. The trap is believing union with a non-regular language must be non-regular.

Q24MSQ1 mark · no negative· Easy

Which of the following statements about threads is/are TRUE?

  1. (A)Threads can only be implemented in kernel space
  2. (B)Each thread has its own file descriptor table for open files
  3. (C)All the threads belonging to a process share a common stack
  4. (D)Threads belonging to a process are by default not protected from each other
Answer: D - show solution

(A) False: user-level threads exist. (B) False: the file descriptor table belongs to the process and is shared by its threads. (C) False: each thread has its own stack. (D) True: threads share one address space, so one thread can read or corrupt another's data. Answer: (D).

Concept: Threads share code, data, heap and open files; each has its own registers, PC and stack. The trap is assuming a shared stack or per-thread file table.

Q25MSQ1 mark · no negative· Easy

Which of the following process state transitions is/are NOT possible?

  1. (A)Running to Ready
  2. (B)Waiting to Running
  3. (C)Ready to Waiting
  4. (D)Running to Terminated
Answer: B, C - show solution

Running to Ready happens on preemption. Running to Terminated happens on exit. Waiting (blocked) to Running is impossible: when the event occurs the process goes to Ready and must be dispatched. Ready to Waiting is impossible: a process can block only by doing something while running. Answer: (B), (C).

Concept: Only a running process can block, and an unblocked process always returns to the ready queue first. The trap is allowing a direct wake-up into Running.

Q26MSQ1 mark · no negative· Easy

Which of the following is/are Bottom-Up Parser(s)?

  1. (A)Shift-reduce Parser
  2. (B)Predictive Parser
  3. (C)LL(1) Parser
  4. (D)LR Parser
Answer: A, D - show solution

Shift-reduce parsers build the parse tree from leaves to root, and LR parsers (SLR, LALR, CLR) are shift-reduce parsers, so both are bottom-up. Predictive and LL(1) parsers are top-down. Answer: (A), (D).

Concept: LL = top-down (leftmost derivation), LR = bottom-up (rightmost derivation in reverse). The trap is mixing up the two L's.

Q27MSQ1 mark · no negative· Easy

Let A and B be two events in a probability space with P(A) = 0.3, P(B) = 0.5, and P(A ∩ B) = 0.1. Which of the following statements is/are TRUE?

  1. (A)The two events A and B are independent
  2. (B)P(A ∪ B) = 0.7
  3. (C)P(A ∩ Bᶜ) = 0.2, where Bᶜ is the complement of the event B
  4. (D)P(Aᶜ ∩ Bᶜ) = 0.4, where Aᶜ and Bᶜ are the complements of the events A and B, respectively
Answer: B, C - show solution

(A) P(A)P(B) = 0.15 ≠ 0.1, so not independent. (B) P(A ∪ B) = 0.3 + 0.5 − 0.1 = 0.7, true. (C) P(A ∩ Bᶜ) = P(A) − P(A ∩ B) = 0.2, true. (D) P(Aᶜ ∩ Bᶜ) = 1 − P(A ∪ B) = 0.3, not 0.4. Answer: (B), (C).

Concept: Inclusion-exclusion and De Morgan's law. The trap in (D) is computing (1 − 0.3)(1 − 0.5) = 0.35 or similar as if independent.

Q28MSQ1 mark · no negative· Moderate

Consider the circuit described below where the gates may have propagation delays. Input X goes directly to one input of a 2-input AND gate, and also through a NOT gate whose output goes to the other input of the AND gate; the AND output is Y (so ideally Y = X · X'). Assume that all signal transitions occur instantaneously and that wires have no delays. Which of the following statements about the circuit is/are CORRECT?

  1. (A)With no propagation delays, the output Y is always logic Zero
  2. (B)With no propagation delays, the output Y is always logic One
  3. (C)With propagation delays, the output Y can have a transient logic One after X transitions from logic Zero to logic One
  4. (D)With propagation delays, the output Y can have a transient logic Zero after X transitions from logic One to logic Zero
Answer: A, C - show solution

Without delays Y = X · X' = 0 always, so (A) is true and (B) false. With a NOT delay, when X rises 0 → 1 the inverter output is still 1 for a moment, so both AND inputs are 1 and Y glitches to 1: (C) true. When X falls 1 → 0, the direct input is already 0, so Y stays 0; and Y was already 0 before, so there is no transient zero to speak of: (D) false. Answer: (A), (C).

Concept: A static hazard: a signal ANDed with its own delayed complement produces a brief pulse on one edge only. The trap is expecting a glitch on both edges.

Q29MSQ1 mark · no negative· Easy

TCP client P successfully establishes a connection to TCP server Q. Let N_P denote the sequence number in the SYN sent from P to Q. Let N_Q denote the acknowledgement number in the SYN ACK from Q to P. Which of the following statements is/are CORRECT?

  1. (A)The sequence number N_P is chosen randomly by P
  2. (B)The sequence number N_P is always 0 for a new connection
  3. (C)The acknowledgement number N_Q is equal to N_P
  4. (D)The acknowledgement number N_Q is equal to N_P + 1
Answer: A, D - show solution

The initial sequence number is chosen (pseudo)randomly to avoid confusion with old segments and spoofing, so (A) true and (B) false. A SYN consumes one sequence number, so Q acknowledges with the next expected number N_P + 1: (D) true, (C) false. Answer: (A), (D).

Concept: SYN and FIN each consume one sequence number even without data. The trap is thinking the ISN starts at 0 (tools like Wireshark show relative numbers).

Q30MSQ1 mark · no negative· Easy

Consider a 5-stage pipelined processor with Instruction Fetch (IF), Instruction Decode (ID), Execute (EX), Memory Access (MEM), and Register Writeback (WB) stages. Which of the following statements about forwarding is/are CORRECT?

  1. (A)In a pipelined execution, forwarding means the result from a source stage of an earlier instruction is passed on to the destination stage of a later instruction
  2. (B)In forwarding, data from the output of the MEM stage can be passed on to the input of the EX stage of the next instruction
  3. (C)Forwarding cannot prevent all pipeline stalls
  4. (D)Forwarding does not require any extra hardware to retrieve the data from the pipeline stages
Answer: A, B, C - show solution

(A) True: that is the definition of forwarding (bypassing). (B) True: the MEM output (e.g., a loaded value or EX/MEM result) can be fed to the EX input of a following instruction. (C) True: a load followed immediately by a use still needs a one-cycle stall. (D) False: forwarding needs extra multiplexers, paths and hazard-detection logic. Answer: (A), (B), (C).

Concept: Forwarding removes most RAW stalls but not the load-use stall, and it costs hardware. The trap is believing it eliminates all stalls.

Q31MSQ1 mark · no negative· Easy

Which of the following fields is/are modified in the IP header of a packet going out of a network address translation (NAT) device from an internal network to an external network?

  1. (A)Source IP
  2. (B)Destination IP
  3. (C)Header Checksum
  4. (D)Total Length
Answer: A, C - show solution

Outbound through NAT, the private source IP is replaced by the NAT's public IP (and the transport port, but that is not in the IP header). Changing any header field forces recomputation of the IP header checksum. The destination IP and total length are unchanged. Answer: (A), (C).

Concept: NAT rewrites the source address on the way out and the destination on the way in, and every rewrite changes the checksum. The trap is forgetting the checksum.

Q32NAT1 mark · no negative· Moderate

Let A and B be non-empty finite sets such that there exist one-to-one and onto functions (i) from A to B and (ii) from A × A to A ∪ B. The number of possible values of |A| is __________

Answer: 2 - show solution

A bijection A → B gives |A| = |B| = n. A bijection A × A → A ∪ B gives n² = |A ∪ B|, and n ≤ |A ∪ B| ≤ 2n. So n² ≤ 2n, i.e., n ≤ 2. n = 1: take A = B, |A ∪ B| = 1 = 1². n = 2: take A, B disjoint, |A ∪ B| = 4 = 2². Both work, so 2 values. Answer: 2.

Concept: Bijection means equal cardinality; then bound |A ∪ B| between n and 2n. The trap is forgetting that A and B may overlap or be disjoint as needed.

Q33NAT1 mark · no negative· Moderate

Consider the operator precedence and associativity rules for the integer arithmetic operators given in the table below. Operator Precedence Associativity + Highest Left − High Right ∗ Medium Right / Low Right The value of the expression 3 + 1 + 5 ∗ 2 / 7 + 2 − 4 − 7 − 6 / 2 as per the above rules is __________

Answer: 6 - show solution

/ binds loosest and is right-associative, so the expression is (3 + 1 + 5 ∗ 2) / ((7 + 2 − 4 − 7 − 6) / 2). Left part: + binds before ∗, so (3 + 1 + 5) ∗ 2 = 18. Middle: + first gives 9 − 4 − 7 − 6, and right-associative − gives 9 − (4 − (7 − 6)) = 9 − 3 = 6. Then 6 / 2 = 3 and 18 / 3 = 6. Answer: 6.

Concept: Split at the lowest-precedence operator first, applying its associativity, then recurse. The trap is evaluating − left to right.

Q34NAT1 mark · no negative· Easy

The number of spanning trees in a complete graph of 4 vertices labelled A, B, C, and D is _________

Answer: 16 - show solution

By Cayley's formula the complete graph Kₙ on n labelled vertices has nⁿ⁻² spanning trees. For n = 4: 4² = 16. Answer: 16.

Concept: Cayley's formula nⁿ⁻² counts labelled spanning trees. The trap is counting non-isomorphic trees (only 2) instead of labelled ones.

Q35NAT1 mark · no negative· Easy

Consider the following two relations, R(A,B) and S(A,C): R: A B S: A C 10 20 10 90 20 30 30 45 30 40 40 80 30 50 50 95 The total number of tuples obtained by evaluating the following expression σ_{B<C}(R ⋈_{R.A=S.A} S) is _________

Answer: 2 - show solution

Join on A: R(10,20) with S(10,90); R(30,40) with S(30,45); R(30,50) with S(30,45). R tuples with A = 20 and 50 have no match. Apply B < C: 20 < 90 yes, 40 < 45 yes, 50 < 45 no. Result has 2 tuples. Answer: 2.

Concept: Do the equi-join first, then filter. The trap is forgetting that A = 30 appears twice in R and produces two joined rows.

Q36MCQ2 marks · -2/3· Moderate

Consider a network path P−Q−R between nodes P and R via router Q. Node P sends a file of size 10⁶ bytes to R via this path by splitting the file into chunks of 10³ bytes each. Node P sends these chunks one after the other without any wait time between the successive chunk transmissions. Assume that the size of extra headers added to these chunks is negligible, and that the chunk size is less than the MTU. Each of the links P−Q and Q−R has a bandwidth of 10⁶ bits/sec, and negligible propagation latency. Router Q immediately transmits every packet it receives from P to R, with negligible processing and queueing delays. Router Q can simultaneously receive on link P−Q and transmit on link Q−R. Assume P starts transmitting the chunks at time t = 0. Which one of the following options gives the time (in seconds, rounded off to 3 decimal places) at which R receives all the chunks of the file?

  1. (A)8.000
  2. (B)8.008
  3. (C)15.992
  4. (D)16.000
Answer: B - show solution

There are 10⁶/10³ = 1000 chunks of 8000 bits; each takes 8000/10⁶ = 8 ms per link. P finishes sending the last chunk at 1000 × 8 ms = 8.000 s. Q is store-and-forward and pipelined, so the last chunk then needs one more 8 ms transmission on Q−R. R has everything at 8.000 + 0.008 = 8.008 s. Answer: (B) 8.008.

Concept: Pipelined store-and-forward: total = (number of packets + hops − 1) × per-packet time. The trap is doubling the whole file time (16 s) as if Q waited for the entire file.

Q37MCQ2 marks · -2/3· Easy

Consider the following syntax-directed definition (SDD). S → DHTU { S.val = D.val + H.val + T.val + U.val; } D → "M" D1 { D.val = 5 + D1.val; } D → ϵ { D.val = −5; } H → "L" H1 { H.val = 5 ∗ 10 + H1.val; } H → ϵ { H.val = −10; } T → "C" T1 { T.val = 5 ∗ 100 + T1.val; } T → ϵ { T.val = −5; } U → "K" { U.val = 5; } Given "MMLK" as the input, which one of the following options is the CORRECT value computed by the SDD (in the attribute S.val)?

  1. (A)45
  2. (B)50
  3. (C)55
  4. (D)65
Answer: A - show solution

Parse MMLK as D = MM, H = L, T = ϵ, U = K. D.val = 5 + 5 + (−5) = 5. H.val = 50 + (−10) = 40. T.val = −5. U.val = 5. S.val = 5 + 40 − 5 + 5 = 45. Answer: (A) 45.

Concept: Evaluate synthesized attributes bottom-up, remembering the ϵ productions contribute their own (negative) values. The trap is ignoring the ϵ values and getting 65.

Q38MCQ2 marks · -2/3· Moderate

Consider the following grammar G, with S as the start symbol. The grammar G has three incomplete productions denoted by (1), (2), and (3). S → daT | (1) T → aS | bT | (2) R → (3) | ϵ The set of terminals is {a, b, c, d, f}. The FIRST and FOLLOW sets of the different non-terminals are as follows. FIRST(S) = {c, d, f}, FIRST(T) = {a, b, ϵ}, FIRST(R) = {c, ϵ} FOLLOW(S) = FOLLOW(T) = {c, f, $}, FOLLOW(R) = {f} Which one of the following options CORRECTLY fills in the incomplete productions?

  1. (A)(1) S → Rf (2) T → ϵ (3) R → cTR
  2. (B)(1) S → fR (2) T → ϵ (3) R → cTR
  3. (C)(1) S → fR (2) T → cT (3) R → cR
  4. (D)(1) S → Rf (2) T → cT (3) R → cR
Answer: A - show solution

ϵ ∈ FIRST(T) and c ∉ FIRST(T), so (2) is T → ϵ, ruling out (C) and (D). S → fR would put R at the end of S, so FOLLOW(R) would include FOLLOW(S) = {c, f, $}, not just {f}; with S → Rf, FIRST(S) = {d} ∪ {c, f} and FOLLOW(R) = {f}. With R → cTR: FOLLOW(T) gets FIRST(R) − ϵ = {c} and, since R is nullable, FOLLOW(R) = {f}; with FOLLOW(S) from T → aS this matches {c, f, $}. Answer: (A).

Concept: Work backwards from the given sets: ϵ in FIRST forces an ϵ production, and a small FOLLOW set means the non-terminal is never at the end of a longer right side. The trap is choosing S → fR, which gives the right FIRST(S) but the wrong FOLLOW(R).

Q39MCQ2 marks · -2/3· Moderate

Consider the following pseudo-code. Which one of the following options CORRECTLY specifies the number of basic blocks and the number of instructions in the largest basic block, respectively?

L1:  t1 = -1
L2:  t2 = 0
L3:  t3 = 0
L4:  t4 = 4 * t3
L5:  t5 = 4 * t2
L6:  t6 = t5 * M
L7:  t7 = t4 + t6
L8:  t8 = a[t7]
L9:  if t8 <= max goto L11
L10: t1 = t8
L11: t3 = t3 + 1
L12: if t3 < M goto L4
L13: t2 = t2 + 1
L14: if t2 < N goto L3
L15: max = t1
  1. (A)6 and 6
  2. (B)6 and 7
  3. (C)7 and 7
  4. (D)7 and 6
Answer: D - show solution

Leaders: L1 (first), L3 (target of L14), L4 (target of L12), L11 (target of L9), and the instructions after each jump: L10, L13, L15. Blocks: L1-L2 (2), L3 (1), L4-L9 (6), L10 (1), L11-L12 (2), L13-L14 (2), L15 (1). That is 7 blocks, the largest with 6 instructions. Answer: (D) 7 and 6.

Concept: Leaders are the first instruction, every jump target, and every instruction following a jump. The trap is missing L3 as a separate leader, which merges it into a 7-instruction block.

Q40MCQ2 marks · -2/3· Moderate

Consider the following two threads T1 and T2 that update two shared variables a and b. Assume that initially a = b = 1. Though context switching between threads can happen at any time, each statement of T1 or T2 is executed atomically without interruption. T1: a = a + 1; b = b + 1; T2: b = 2 * b; a = 2 * a; Which one of the following options lists all the possible combinations of values of a and b after both T1 and T2 finish execution?

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

Each variable is touched once by each thread, so only the relative order on each variable matters. For a: (a+1 then 2a) gives 4, (2a then a+1) gives 3. For b: (2b then b+1) gives 3, (b+1 then 2b) gives 4. Program order forbids 2a before a+1 together with b+1 before 2b (that would need a cycle), so (3, 4) is impossible. Enumerating all 6 interleavings gives (4, 4), (4, 3) four times, and (3, 3). Answer: (A).

Concept: Enumerate interleavings respecting each thread's program order. The trap is including (a = 3, b = 4), which needs T2's second statement before T1's first while T1's second precedes T2's first.

Q41MCQ2 marks · -2/3· Moderate

An array [82, 101, 90, 11, 111, 75, 33, 131, 44, 93] is heapified. Which one of the following options represents the first three elements in the heapified array?

  1. (A)82, 90, 101
  2. (B)82, 11, 93
  3. (C)131, 11, 93
  4. (D)131, 111, 90
Answer: D - show solution

Build a max-heap bottom-up on [82, 101, 90, 11, 111, 75, 33, 131, 44, 93]. i = 5 (111, child 93): no change. i = 4 (11, children 131, 44): swap with 131. i = 3 (90, children 75, 33): no change. i = 2 (101, children 131, 111): swap with 131; 101 then beats 11, 44. i = 1 (82, children 131, 90): swap with 131; 82 sinks below 111, then below 93. Result starts 131, 111, 90. A min-heap would start with 11, which no option matches with correct children. Answer: (D) 131, 111, 90.

Concept: Heapify sifts down from the last internal node to the root. The trap is inserting one element at a time or forgetting to continue the sift-down after a swap.

Q42MCQ2 marks · -2/3· Moderate

Consider the following recurrence relation: T(n) = √n · T(√n) + n for n ≥ 1, T(n) = 1 for n = 1. Which one of the following options is CORRECT?

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

Divide by n: T(n)/n = T(√n)/√n + 1. Let S(n) = T(n)/n, so S(n) = S(√n) + 1. Taking square roots repeatedly reaches a constant after log log n steps, so S(n) = Θ(log log n) and T(n) = Θ(n log log n). Answer: (A).

Concept: Normalise by n (or substitute n = 2^(2^k)) to turn the square-root recurrence into a simple count. The trap is treating it like T(n) = 2T(n/2) + n and answering n log n.

Q43MCQ2 marks · -2/3· Moderate

Consider a binary min-heap containing 105 distinct elements. Let k be the index (in the underlying array) of the maximum element stored in the heap. The number of possible values of k is

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

In a min-heap the maximum has no larger descendant, so it must be a leaf, and any leaf can hold it. With 1-based indexing, nodes 1 to ⌊105/2⌋ = 52 are internal and 53 to 105 are leaves, i.e., 105 − 52 = 53 leaves. Answer: (A) 53.

Concept: Number of leaves in an n-node heap is ⌈n/2⌉. The trap is counting only the last level.

Q44MSQ2 marks · no negative· Easy

The symbol → indicates functional dependency in the context of a relational database. Which of the following options is/are TRUE?

  1. (A)(X, Y) → (Z, W) implies X → (Z, W)
  2. (B)(X, Y) → (Z, W) implies (X, Y) → Z
  3. (C)((X, Y) → Z and W → Y) implies (X, W) → Z
  4. (D)(X → Y and Y → Z) implies X → Z
Answer: B, C, D - show solution

(A) False: a determinant cannot be shrunk; X alone need not determine Z, W. (B) True by decomposition. (C) True by pseudo-transitivity: W → Y gives XW → XY, and XY → Z, so XW → Z. (D) True by transitivity. Answer: (B), (C), (D).

Concept: Armstrong's axioms let you split the right side or augment the left, never drop attributes from the left. The trap is accepting (A).

Q45MSQ2 marks · no negative· Hard

Let be a directed graph and a depth first search (DFS) spanning tree in that is rooted at a vertex . Suppose is also a breadth first search (BFS) tree in , rooted at . Which of the following statements is/are TRUE for every such graph and tree ?

  1. (A)There are no back-edges in with respect to the tree
  2. (B)There are no cross-edges in with respect to the tree
  3. (C)There are no forward-edges in with respect to the tree
  4. (D)The only edges in are the edges in
Answer: C - show solution

Forward edges: an edge u → w to a non-child descendant puts w at least two levels below u, but BFS from v would discover w at depth(u) + 1 via that edge, so T could not be a BFS tree. Hence no forward edges: (C) true. Back edges can exist (v → u and u → v). Cross edges can exist: with v → a, v → b, b → a, DFS visits a then b, and b → a is a cross edge, while BFS gives the same tree. So (A), (B), (D) fail. Answer: (C).

Concept: A BFS tree has no edge that skips a level downward. The trap is assuming the tree must contain every edge or that cross edges are impossible.

Q46MSQ2 marks · no negative· Moderate

Consider the following read-write schedule S over three transactions T1, T2, and T3, where the subscripts in the schedule indicate transaction IDs: S: r1(z); w1(z); r2(x); r3(y); w3(y); r2(y); w2(x); w2(y); Which of the following transaction schedules is/are conflict equivalent to S?

  1. (A)T1T2T3
  2. (B)T1T3T2
  3. (C)T3T2T1
  4. (D)T3T1T2
Answer: B, C, D - show solution

Conflicts on y: r3(y) before w2(y), w3(y) before r2(y), w3(y) before w2(y), all giving T3 → T2. T1 touches only z, which nobody else uses, and x is used only by T2. The precedence graph has the single edge T3 → T2, so any serial order with T3 before T2 is conflict equivalent: T1T3T2, T3T2T1, T3T1T2. Answer: (B), (C), (D).

Concept: Conflict-equivalent serial orders are the topological orders of the precedence graph. The trap is assuming T1 must come first because it starts first.

Q47MSQ2 marks · no negative· Easy

Consider a Boolean expression given by F(X, Y, Z) = Σ(3,5,6,7). Which of the following statements is/are CORRECT?

  1. (A)F(X, Y, Z) = Π(0,1,2,4)
  2. (B)F(X, Y, Z) = XY + YZ + XZ
  3. (C)F(X, Y, Z) is independent of input Y
  4. (D)F(X, Y, Z) is independent of input X
Answer: A, B - show solution

The maxterms are the remaining indices 0, 1, 2, 4, so (A) holds. Minterms 3 (011), 5 (101), 6 (110), 7 (111) are the inputs with at least two 1s, the majority function XY + YZ + XZ, so (B) holds. Majority depends on every input (e.g., F(1,0,0) = 0 but F(1,1,0) = 1), so (C) and (D) are false. Answer: (A), (B).

Concept: Σ and Π use complementary index sets. The trap is writing Π with the same indices as Σ.

Q49MSQ2 marks · no negative· Hard

Let A be any n × m matrix, where m > n. Which of the following statements is/are TRUE about the system of linear equations Ax = 0?

  1. (A)There exist at least m − n linearly independent solutions to this system
  2. (B)There exist m − n linearly independent vectors such that every solution is a linear combination of these vectors
  3. (C)There exists a non-zero solution in which at least m − n variables are 0
  4. (D)There exists a solution in which at least n variables are non-zero
Answer: A - show solution

rank(A) ≤ n, so the null space has dimension m − rank ≥ m − n: (A) true. (B) needs nullity exactly m − n; for A = 0 the nullity is m, so false. (C) fails for n = 1, m = 2, A = [1 1]: solutions (t, −t) have no zero entry when non-zero. (D) fails for A = [[1,0,0],[0,1,0]] (n = 2, m = 3): solutions (0, 0, t) have at most one non-zero entry. Answer: (A).

Concept: Rank-nullity gives a lower bound on the solution space, not an exact size. The trap is (B), which treats the bound as equality.

Q50MSQ2 marks · no negative· Moderate

Consider the 5-state DFA M accepting the language L(M) ⊂ (0 + 1)*, given by the transition table below (state 1 is the start state and the only accepting state). For any string w ∈ (0 + 1)* let n₀(w) be the number of 0's in w and n₁(w) be the number of 1's in w. State on 0 on 1 →*1 2 4 2 3 1 3 1 2 4 1 5 5 4 1 Which of the following statements is/are FALSE?

  1. (A)States 2 and 4 are distinguishable in M
  2. (B)States 3 and 4 are distinguishable in M
  3. (C)States 2 and 5 are distinguishable in M
  4. (D)Any string w with n₀(w) = n₁(w) is in L(M)
Answer: B, C - show solution

Each 0 adds 1 and each 1 subtracts 1 from (n₀ − n₁) mod 3: state 1 is 0, states 2 and 5 are 1 (≡ −2), states 3 and 4 are 2 (≡ −1). So L(M) = {w : n₀ − n₁ ≡ 0 mod 3}. States with the same residue are equivalent: 3 ≡ 4 and 2 ≡ 5, so (B) and (C) are false. 2 and 4 differ (input 1 sends 2 to 1, accept, and 4 to 5, reject), so (A) is true. n₀ = n₁ gives residue 0, so (D) is true. Answer: (B), (C).

Concept: Find the invariant each state tracks; equal invariants mean equivalent states. The trap is the question asking for FALSE statements.

Q51MSQ2 marks · no negative· Hard

The chromatic number of a graph is the minimum number of colours used in a proper colouring of the graph. Let G be any graph with n vertices and chromatic number k. Which of the following statements is/are always TRUE?

  1. (A)G contains a complete subgraph with k vertices
  2. (B)G contains an independent set of size at least n/k
  3. (C)G contains at least k(k − 1)/2 edges
  4. (D)G contains a vertex of degree at least k
Answer: B, C - show solution

(A) False: the 5-cycle has k = 3 but no triangle. (B) True: an optimal colouring splits n vertices into k independent colour classes, so one has at least n/k. (C) True: in an optimal colouring every pair of colour classes must have an edge between them (else merge them), giving at least C(k,2) edges. (D) False: K_k has chromatic number k but maximum degree k − 1. Answer: (B), (C).

Concept: Colour classes are independent sets, and optimality forces an edge between every pair of classes. The trap is (A): high chromatic number does not require a clique.

Q52MSQ2 marks · no negative· Moderate

Consider the operators ◊ and □ defined by a ◊ b = a + 2b, a □ b = ab, for positive integers. Which of the following statements is/are TRUE?

  1. (A)Operator ◊ obeys the associative law
  2. (B)Operator □ obeys the associative law
  3. (C)Operator ◊ over the operator □ obeys the distributive law
  4. (D)Operator □ over the operator ◊ obeys the distributive law
Answer: B, D - show solution

(A) (a◊b)◊c = a + 2b + 2c but a◊(b◊c) = a + 2b + 4c: not associative. (B) Multiplication is associative: true. (C) a◊(b□c) = a + 2bc, while (a◊b)□(a◊c) = (a + 2b)(a + 2c): false. (D) a□(b◊c) = a(b + 2c) = ab + 2ac = (a□b)◊(a□c), and (b◊c)□a = ba + 2ca = (b□a)◊(c□a): true. Answer: (B), (D).

Concept: Check each law symbolically; one counterexample disproves it. The trap is assuming ◊ is associative because it is built from +.

Q53MSQ2 marks · no negative· Moderate

Consider two set-associative cache memory architectures: WBC, which uses the write back policy, and WTC, which uses the write through policy. Both of them use the LRU (Least Recently Used) block replacement policy. The cache memory is connected to the main memory. Which of the following statements is/are TRUE?

  1. (A)A read miss in WBC never evicts a dirty block
  2. (B)A read miss in WTC never triggers a write back operation of a cache block to main memory
  3. (C)A write hit in WBC can modify the value of the dirty bit of a cache block
  4. (D)A write miss in WTC always writes the victim cache block to main memory before loading the missed block to the cache
Answer: B, C - show solution

(A) False: in a write-back cache the LRU victim of a read miss may be dirty and must be written back. (B) True: write-through keeps memory current, so blocks are never dirty and evictions need no write-back. (C) True: a write hit in write-back sets the dirty bit. (D) False: write-through has no dirty victims to write back, and with no-write-allocate a write miss does not even load the block. Answer: (B), (C).

Concept: Write-back defers memory updates using a dirty bit; write-through updates memory on every write. The trap is (A), forgetting that dirty blocks can be chosen as victims on reads.

Q54NAT2 marks · no negative· Easy

Consider a 512 GB hard disk with 32 storage surfaces. There are 4096 sectors per track and each sector holds 1024 bytes of data. The number of cylinders in the hard disk is _________

Answer: 4096 - show solution

Capacity per track = 4096 × 1024 B = 2²² B. Per cylinder (32 surfaces) = 2²⁷ B. 512 GB = 2³⁹ B. Cylinders = 2³⁹ / 2²⁷ = 2¹² = 4096. Answer: 4096.

Concept: Cylinders = capacity / (surfaces × sectors per track × bytes per sector). The trap is dividing by tracks per surface or forgetting the surfaces.

Q55NAT2 marks · no negative· Moderate

The baseline execution time of a program on a 2 GHz single core machine is 100 nanoseconds (ns). The code corresponding to 90% of the execution time can be fully parallelized. The overhead for using an additional core is 10 ns when running on a multicore system. Assume that all cores in the multicore system run their share of the parallelized code for an equal amount of time. The number of cores that minimize the execution time of the program is ________

Answer: 3 - show solution

Serial part = 10 ns, parallel part = 90 ns. With n cores: time = 10 + 90/n + 10(n − 1). n = 1: 100. n = 2: 10 + 45 + 10 = 65. n = 3: 10 + 30 + 20 = 60. n = 4: 10 + 22.5 + 30 = 62.5. n = 5: 10 + 18 + 40 = 68. Minimum at n = 3. Answer: 3.

Concept: Amdahl's law with a per-core overhead has an optimum where added overhead outweighs the parallel saving. The trap is charging the overhead for every core, including the first.

Q56NAT2 marks · no negative· Easy

A given program has 25% load/store instructions. Suppose the ideal CPI (cycles per instruction) without any memory stalls is 2. The program exhibits 2% miss rate on instruction cache and 8% miss rate on data cache. The miss penalty is 100 cycles. The speedup (rounded off to two decimal places) achieved with a perfect cache (i.e., with NO data or instruction cache misses) is _________

Answer: 3 - show solution

Memory stall cycles per instruction = instruction fetch misses + data misses = 1 × 0.02 × 100 + 0.25 × 0.08 × 100 = 2 + 2 = 4. Real CPI = 2 + 4 = 6. Perfect cache CPI = 2. Speedup = 6/2 = 3.00. Answer: 3.

Concept: Every instruction is fetched, but only loads/stores access the data cache. The trap is applying the data miss rate to all instructions.

Q57NAT2 marks · no negative· Moderate

Consider the following code snippet using the fork() and wait() system calls. Assume that the code compiles and runs correctly, and that the system calls run successfully without any errors. The total number of times the printf statement is executed is _______

int x = 3;
while(x > 0) {
  fork();
  printf("hello");
  wait(NULL);
  x--;
}
Answer: 14 - show solution

Every process alive at the start of an iteration forks, and both parent and child print and continue the loop. Processes double each iteration: 2 print in iteration 1, 4 in iteration 2, 8 in iteration 3. wait() only affects ordering. Total = 2 + 4 + 8 = 14. Answer: 14.

Concept: With fork inside a loop, each iteration doubles the processes and each of them executes the printf. The trap is counting only the final 8 processes.

Q58NAT2 marks · no negative· Moderate

Consider the entries shown below in the forwarding table of an IP router. Each entry consists of an IP prefix and the corresponding next hop router for packets whose destination IP address matches the prefix. The notation "/N" in a prefix indicates a subnet mask with the most significant N bits set to 1. Prefix Next hop router 10.1.1.0/24 R1 10.1.1.128/25 R2 10.1.1.64/26 R3 10.1.1.192/26 R4 This router forwards 20 packets each to 5 hosts. The IP addresses of the hosts are 10.1.1.16, 10.1.1.72, 10.1.1.132, 10.1.1.191, and 10.1.1.205. The number of packets forwarded via the next hop router R2 is _______

Answer: 40 - show solution

Longest prefix match on the last octet. /25 R2 covers 128-255; /26 R3 covers 64-127; /26 R4 covers 192-255. 16: only /24, R1. 72: R3. 132: R2 (not in 192-255). 191: R2. 205: R4 (longer than /25). R2 gets 2 hosts × 20 = 40 packets. Answer: 40.

Concept: Longest prefix match picks the most specific entry. The trap is sending .205 to R2 or .191 to R4.

Q59NAT2 marks · no negative· Moderate

Let G = (V, Σ, S, P) be a context-free grammar in Chomsky Normal Form with Σ = {a, b, c} and V containing 10 variable symbols including the start symbol S. The string w = a³⁰b³⁰c³⁰ is derivable from S. The number of steps (application of rules) in the derivation S →* w is _________

Answer: 179 - show solution

In CNF, a rule A → BC increases the number of symbols by one and a rule A → a turns one variable into a terminal. A string of length n needs n − 1 rules of the first kind and n of the second: 2n − 1 steps. Here n = 90, so 179. Answer: 179.

Concept: CNF derivations of a length-n string always take 2n − 1 steps; the number of variables is a distractor. The trap is answering 90 or 89.

Q60NAT2 marks · no negative· Easy

The number of edges present in the forest generated by the DFS traversal of an undirected graph with 100 vertices is 40. The number of connected components in is _________

Answer: 60 - show solution

DFS on an undirected graph gives a spanning forest with one tree per connected component. A forest with V vertices and c trees has V − c edges. So 100 − c = 40 and c = 60. Answer: 60.

Concept: Edges in a spanning forest = vertices − components. The trap is thinking DFS yields a single tree.

Q61NAT2 marks · no negative· Moderate

Consider the following two regular expressions over the alphabet {0,1}: r = 0* + 1* s = 01* + 10* The total number of strings of length less than or equal to 5, which are neither in r nor in s, is _________

Answer: 44 - show solution

Strings of length 0 to 5: 1 + 2 + 4 + 8 + 16 + 32 = 63. r has ϵ plus 0ᵏ and 1ᵏ for k = 1..5: 11 strings. s has 01ᵏ⁻¹ and 10ᵏ⁻¹ for k = 1..5; the length-1 ones (0, 1) are already in r, leaving 2 × 4 = 8 new strings. Union = 19. Neither: 63 − 19 = 44. Answer: 44.

Concept: Count the union with inclusion-exclusion. The trap is double-counting 0 and 1, which are in both r and s.

Q62NAT2 marks · no negative· Easy

Consider a memory management system that uses a page size of 2 KB. Assume that both the physical and virtual addresses start from 0. Assume that the pages 0, 1, 2, and 3 are stored in the page frames 1, 3, 2, and 0, respectively. The physical address (in decimal format) corresponding to the virtual address 2500 (in decimal format) is _________

Answer: 6596 - show solution

Page size 2048 B. Virtual address 2500 is in page ⌊2500/2048⌋ = 1 with offset 452. Page 1 is in frame 3, so physical address = 3 × 2048 + 452 = 6596. Answer: 6596.

Concept: Split the address into page number and offset, map the page to its frame, keep the offset. The trap is mapping page 1 to frame 1.

Q63NAT2 marks · no negative· Easy

A bag contains 10 red balls and 15 blue balls. Two balls are drawn randomly without replacement. Given that the first ball drawn is red, the probability (rounded off to 3 decimal places) that both balls drawn are red is _________

Answer: 0.37 to 0.38 - show solution

Given the first ball is red, 9 red remain among 24 balls. P(both red | first red) = 9/24 = 0.375. (Equivalently P(both red)/P(first red) = (10/25 × 9/24)/(10/25).) The key accepts 0.37 to 0.38. Answer: 0.375.

Concept: Conditioning on the first draw just changes the second draw's sample space. The trap is giving the unconditional P(both red) = 0.15.

Q64NAT2 marks · no negative· Easy

Consider a digital logic circuit consisting of three 2-to-1 multiplexers M1, M2, and M3. X1 and X2 are inputs 0 and 1 of M1, and X3 and X4 are inputs 0 and 1 of M2. The output Q1 of M1 feeds input 0 of M3 and the output Q2 of M2 feeds input 1 of M3; Y is the output of M3. A, B, and C are the select lines of M1, M2, and M3, respectively. For an instance of inputs X1=1, X2=1, X3=0, and X4=0, the number of combinations of A, B, C that give the output Y=1 is _________

Answer: 4 - show solution

Q1 = 1 whatever A is (both inputs 1). Q2 = 0 whatever B is (both inputs 0). Y = Q1 when C = 0 and Q2 when C = 1, so Y = 1 exactly when C = 0. A and B are free: 2 × 2 = 4 combinations. Answer: 4.

Concept: A mux with equal data inputs ignores its select line. The trap is counting only combinations where A or B take a specific value.

Q65NAT2 marks · no negative· Moderate

Consider sending an IP datagram of size 1420 bytes (including 20 bytes of IP header) from a sender to a receiver over a path of two links with a router between them. The first link (sender to router) has an MTU (Maximum Transmission Unit) size of 542 bytes, while the second link (router to receiver) has an MTU size of 360 bytes. The number of fragments that would be delivered at the receiver is ________

Answer: 6 - show solution

Payload = 1400 B. Link 1 (MTU 542): max payload 522, rounded down to a multiple of 8 = 520, giving 520, 520, 360. Link 2 (MTU 360): max payload 340, rounded to 336. Router refragments each: 520 → 336 + 184; 520 → 336 + 184; 360 → 336 + 24. Fragments are not reassembled at the router, so the receiver gets 6. Answer: 6.

Concept: Fragment payloads (except the last) must be multiples of 8, and only the destination reassembles. The trap is not rounding to 8, or refragmenting the original datagram at the router (giving 5).

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