Organised by IIT Roorkee

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

64 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

Despite his initial hesitation, Rehman's _________ to contribute to the success of the project never wavered. Select the most appropriate option to complete the above sentence.

  1. (A)ambivalence
  2. (B)satisfaction
  3. (C)resolve
  4. (D)revolve
Answer: C - show solution

The blank needs a noun meaning firm determination that "never wavered" despite initial hesitation. Ambivalence means mixed feelings, the opposite of what is described. Satisfaction does not fit "to contribute". Revolve is a verb meaning to rotate. Resolve (noun) means firm determination. Answer: (C) resolve.

Concept: Vocabulary in context: the contrast word "Despite" and the phrase "never wavered" point to determination. The trap is the look-alike word revolve, or ambivalence, which echoes the hesitation rather than contrasting with it.

Q2MCQ1 mark · -1/3· Easy

Bird : Nest :: Bee : _______ Select the correct option to complete the analogy.

  1. (A)Kennel
  2. (B)Hammock
  3. (C)Hive
  4. (D)Lair
Answer: C - show solution

A nest is the home a bird builds. The home of a bee is a hive. A kennel houses a dog, a lair is a wild animal's den and a hammock is a hanging bed. Answer: (C) Hive.

Concept: Animal-to-dwelling analogy. The trap is lair, which is also an animal home but for wild beasts, not bees.

Q3MCQ1 mark · -1/3· Easy

If Pe^x = Qe^(-x) for all real values of x, which one of the following statements is true?

  1. (A)P = Q = 0
  2. (B)P = Q = 1
  3. (C)P = 1; Q = -1
  4. (D)P/Q = 0
Answer: A - show solution

Multiply both sides by e^x: P e^(2x) = Q for every real x. The left side changes with x unless P = 0, and the right side is a constant. So P = 0, and then Q = P e^(2x) = 0. Check: P = Q = 1 gives e^x = e^(-x), true only at x = 0. P/Q = 0 needs Q nonzero, but Q must be 0, so P/Q is undefined. Answer: (A) P = Q = 0.

Concept: An identity holding for all x forces coefficients of independent functions to match; e^x and e^(-x) are linearly independent. The trap is checking a single value like x = 0, which makes option (B) look right.

Q5MCQ1 mark · -1/3· Easy

Let p1 and p2 denote two arbitrary prime numbers. Which one of the following statements is correct for all values of p1 and p2?

  1. (A)p1 + p2 is not a prime number.
  2. (B)p1p2 is not a prime number.
  3. (C)p1 + p2 + 1 is a prime number.
  4. (D)p1p2 + 1 is a prime number.
Answer: B - show solution

(A) fails: 2 + 3 = 5 is prime. (B) p1p2 has divisors 1, p1, p2 and p1p2 with p1, p2 at least 2, so it is never prime: true. (C) fails: 3 + 5 + 1 = 9. (D) fails: 3 x 5 + 1 = 16. Answer: (B) p1p2 is not a prime number.

Concept: "For all values" statements are killed by one counterexample, and the prime 2 is the usual counterexample. A product of two primes always has a nontrivial factor.

Q6MCQ2 marks · -2/3· Moderate

Based only on the conversation below, identify the logically correct inference: "Even if I had known that you were in the hospital, I would not have gone there to see you", Ramya told Josephine.

  1. (A)Ramya knew that Josephine was in the hospital.
  2. (B)Ramya did not know that Josephine was in the hospital.
  3. (C)Ramya and Josephine were once close friends; but now, they are not.
  4. (D)Josephine was in the hospital due to an injury to her leg.
Answer: B - show solution

"Even if I had known" is a counterfactual conditional: it describes a situation contrary to fact. So Ramya did not know that Josephine was in the hospital. Nothing is said about past friendship or the cause of the hospital stay, so (C) and (D) are not supported, and (A) contradicts the counterfactual. Answer: (B).

Concept: Past-perfect "had known" signals an unreal past condition. The trap is reading emotional content (a broken friendship) that the sentence does not state.

Q7MCQ2 marks · -2/3· Moderate

If IMAGE and FIELD are coded as FHBNJ and EMFJG respectively then, which one among the given options is the most appropriate code for BEACH ?

  1. (A)CEADP
  2. (B)IDBFC
  3. (C)JGIBC
  4. (D)IBCEC
Answer: B - show solution

IMAGE reversed is EGAMI; shifting each letter forward by one gives FHBNJ. FIELD reversed is DLEIF; shifted by one gives EMFJG, confirming the rule. BEACH reversed is HCAEB; shifted by one gives IDBFC. Answer: (B) IDBFC.

Concept: Coding-decoding: test reversal and letter shifts together, and verify the rule on the second example before applying it.

Q8MCQ2 marks · -2/3· Easy

Which one of the following options is correct for the given data in the table? Iteration (i) 0 1 2 3 Input (I) 20 -4 10 15 Output (X) 20 16 26 41 Output (Y) 20 -80 -800 -12000

  1. (A)X(i) = X(i - 1) + I(i); Y(i) = Y(i - 1)I(i); i > 0
  2. (B)X(i) = X(i - 1)I(i); Y(i) = Y(i - 1) + I(i); i > 0
  3. (C)X(i) = X(i - 1)I(i); Y(i) = Y(i - 1)I(i); i > 0
  4. (D)X(i) = X(i - 1) + I(i); Y(i) = Y(i - 1)I(i - 1); i > 0
Answer: A - show solution

X: 20 + (-4) = 16, 16 + 10 = 26, 26 + 15 = 41, so X(i) = X(i-1) + I(i). Y: 20 x (-4) = -80, -80 x 10 = -800, -800 x 15 = -12000, so Y(i) = Y(i-1)I(i). Option (D) would give Y(1) = 20 x 20 = 400. Answer: (A).

Concept: Fit a recurrence by testing each candidate on the first step, then confirm on the rest. The trap in (D) is the off-by-one index I(i-1).

Q9MCQ2 marks · -2/3· Moderate

PQRS is a square of side 2 cm and PLMN is a rectangle. The corner L of the rectangle is on the side QR. Side MN of the rectangle passes through the corner S of the square. What is the area (in cm²) of the rectangle PLMN? Note: The figure shown is representative.

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

Triangle PLS has base PL and its third vertex S lies on MN, the side opposite PL. So its height over PL equals the rectangle's width, and area(PLS) = half of area(PLMN). Viewed inside the square, triangle PLS has base PS = 2 and L on QR, which is parallel to PS at distance 2, so area(PLS) = (1/2)(2)(2) = 2. Hence area(PLMN) = 2 x 2 = 4 cm². Answer: (D) 4.

Concept: A triangle on one side of a parallelogram with its apex on the opposite side has half its area. The same triangle is half the square, so rectangle and square are equal. Trying to find the rectangle's sides directly is the slow trap.

Q10MCQ2 marks · -2/3· Moderate

A river system consists of 7 segments, marked P, Q, R, S, T, U and V. It splits the land into 5 zones, marked Z1, Z2, Z3, Z4 and Z5. From the (representative) figure, the zones on either side of each segment are: P separates Z1 and Z2; R separates Z2 and Z3; Q separates Z1 and Z3; S separates Z1 and Z5; T separates Z3 and Z5; V separates Z3 and Z4; U separates Z4 and Z5. We need to connect these zones using the least number of bridges. Out of the following options, which one is correct?

  1. (A)Bridges on P, Q, and T
  2. (B)Bridges on P, Q, S, and T
  3. (C)Bridges on Q, R, T, and V
  4. (D)Bridges on P, Q, S, U, and V
Answer: C - show solution

Treat zones as vertices and bridges as edges. Connecting 5 zones needs at least 4 bridges forming a spanning tree, so (A) with 3 bridges is impossible and (D) with 5 is not least. (B) P, Q, S, T joins Z1-Z2, Z1-Z3, Z1-Z5, Z3-Z5: Z4 is never reached. (C) Q, R, T, V joins Z1-Z3, Z2-Z3, Z3-Z5, Z3-Z4: all five zones connected with 4 bridges. Answer: (C).

Concept: Minimum connections for n regions is n - 1, a spanning tree. The trap is counting bridges without checking that every zone, here Z4, is actually reached.

Q11MCQ1 mark · -1/3· Easy

If A = [[1, 2], [2, -1]], then which ONE of the following is A⁸?

  1. (A)[[25, 0], [0, 25]]
  2. (B)[[125, 0], [0, 125]]
  3. (C)[[625, 0], [0, 625]]
  4. (D)[[3125, 0], [0, 3125]]
Answer: C - show solution

A² = [[1+4, 2-2], [2-2, 4+1]] = [[5, 0], [0, 5]] = 5I. Then A⁸ = (A²)⁴ = 5⁴ I = 625 I. Answer: (C) [[625, 0], [0, 625]].

Concept: Squaring first exposes A² as a scalar matrix, so high powers are immediate. Equivalently the eigenvalues are ±√5. The trap is stopping at A⁴ = 25I and picking (A).

Q12MCQ1 mark · -1/3· Easy

The value of x such that x > 1, satisfying the equation ∫ from 1 to x of t ln t dt = 1/4, is

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

By parts: ∫ t ln t dt = (t²/2) ln t - t²/4. From 1 to x: (x²/2) ln x - x²/4 + 1/4. Setting this equal to 1/4 gives x²(2 ln x - 1)/4 = 0, so ln x = 1/2 and x = √e. Answer: (A) √e.

Concept: Integration by parts with u = ln t. Forgetting the lower-limit term +1/4 is the usual slip and leads to a wrong equation.

Q13MCQ1 mark · -1/3· Easy

Consider a binary tree T in which every node has either zero or two children. Let n > 0 be the number of nodes in T. Which ONE of the following is the number of nodes in T that have exactly two children?

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

Let I be internal nodes (two children each) and L leaves. Edges = n - 1 = 2I, so I = (n - 1)/2. Check: a single node gives 0; a root with two leaves gives n = 3, I = 1. Answer: (B) (n - 1)/2.

Concept: Full binary tree counting: every non-root node has one parent edge, and every internal node contributes two. Also L = I + 1, so n is always odd.

Q14MCQ1 mark · -1/3· Easy

Let L, M, and N be non-singular matrices of order 3 satisfying the equations L² = L⁻¹, M = L⁸ and N = L². Which ONE of the following is the value of the determinant of (M - N)?

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

L² = L⁻¹ gives L³ = I. Then M = L⁸ = L⁶ L² = L², so M = N and M - N is the zero matrix. det(M - N) = 0. Answer: (A) 0.

Concept: Reduce powers using L³ = I. The trap is computing det L instead of noticing M and N are the same matrix.

Q15MCQ1 mark · -1/3· Easy

Let P(x) be an arbitrary predicate over the domain of natural numbers. Which ONE of the following statements is TRUE?

  1. (A)(P(0) ∧ (∀x [P(x) ⇒ P(x + 1)])) ⇒ (∀x P(x))
  2. (B)(P(0) ∧ (∀x [P(x) ⇒ P(x - 1)])) ⇒ (∀x P(x))
  3. (C)(P(1000) ∧ (∀x [P(x) ⇒ P(x - 1)])) ⇒ (∀x P(x))
  4. (D)(P(1000) ∧ (∀x [P(x) ⇒ P(x + 1)])) ⇒ (∀x P(x))
Answer: A - show solution

(A) is the principle of mathematical induction, valid for every predicate. (B) take P(x) true only at 0: the step P(x) ⇒ P(x-1) holds, yet not all P(x). (C) take P(x) true for x ≤ 1000: premises hold but P(1001) is false. (D) take P(x) true for x ≥ 1000: premises hold but P(0) is false. Answer: (A).

Concept: Induction must start at the least element and step upward. Each wrong option covers only a ray of naturals, shown by a predicate true exactly on that ray.

Q16MCQ1 mark · -1/3· Easy

Consider the following statements: (i) Address Resolution Protocol (ARP) provides a mapping from an IP address to the corresponding hardware (link-layer) address. (ii) A single TCP segment from a sender S to a receiver R cannot carry both data from S to R and acknowledgement for a segment from R to S. Which ONE of the following is CORRECT?

  1. (A)Both (i) and (ii) are TRUE
  2. (B)(i) is TRUE and (ii) is FALSE
  3. (C)(i) is FALSE and (ii) is TRUE
  4. (D)Both (i) and (ii) are FALSE
Answer: B - show solution

(i) ARP maps an IPv4 address to the MAC (link-layer) address on the local network: true. (ii) TCP supports piggybacking: a data segment from S to R carries the ACK flag and acknowledgement number for data received from R, so (ii) is false. Answer: (B) (i) is TRUE and (ii) is FALSE.

Concept: Tests ARP's direction (IP to MAC, not the reverse, which was RARP) and TCP piggybacking of ACKs on data segments.

Q17MCQ1 mark · -1/3· Easy

Consider the routing protocols given in List I and the names given in List II: List I List II (i) Distance vector routing (a) Bellman-Ford (ii) Link state routing (b) Dijkstra For matching of items in List I with those in List II, which ONE of the following options is CORRECT?

  1. (A)(i) - (a) and (ii) - (b)
  2. (B)(i) - (a) and (ii) - (a)
  3. (C)(i) - (b) and (ii) - (a)
  4. (D)(i) - (b) and (ii) - (b)
Answer: A - show solution

Distance vector routing (for example RIP) computes routes with the distributed Bellman-Ford algorithm. Link state routing (for example OSPF) floods the topology and each router runs Dijkstra's algorithm. Answer: (A) (i) - (a) and (ii) - (b).

Concept: Distance vector uses neighbour-only information iteratively (Bellman-Ford); link state needs the full map and a single-source shortest path computation (Dijkstra).

Q18MCQ1 mark · -1/3· Moderate

A machine receives an IPv4 datagram. The protocol field of the IPv4 header has the protocol number of a protocol X. Which ONE of the following is NOT a possible candidate for X?

  1. (A)Internet Control Message Protocol (ICMP)
  2. (B)Internet Group Management Protocol (IGMP)
  3. (C)Open Shortest Path First (OSPF)
  4. (D)Routing Information Protocol (RIP)
Answer: D - show solution

The IPv4 protocol field names the protocol carried directly inside the IP payload. ICMP (1), IGMP (2) and OSPF (89) are carried directly in IP. RIP runs over UDP (port 520), so the protocol field would say UDP (17), never RIP. Answer: (D) RIP.

Concept: Know which protocols sit directly on IP. The trap is assuming all routing protocols are alike: OSPF is directly over IP, RIP over UDP, BGP over TCP.

Q19MCQ1 mark · -1/3· Moderate

Consider the following C program. Which ONE of the following will be the output of the program?

#include <stdio.h>
void stringcopy(char *, char *);
int main(){
    char a[30] = "@#Hello World!";
    stringcopy(a, a + 2);
    printf("%s\n", a);
    return 0;
}
void stringcopy(char *s, char *t) {
    while(*t)
        *s++ = *t++;
}
  1. (A)@#Hello World!
  2. (B)Hello World!
  3. (C)ello World!
  4. (D)Hello World!d!
Answer: D - show solution

a holds "@#Hello World!" in a[0..13] with '\0' at a[14]. stringcopy copies from a+2 to a, character by character, while *t is not '\0': the 12 characters "Hello World!" go to a[0..11]. The loop stops at the terminator without copying it. a[12] and a[13] still hold 'd' and '!', and a[14] is '\0'. printf prints "Hello World!d!". Answer: (D).

Concept: The copy loop omits the null terminator, so leftover characters of the old string stay visible. The trap is answering (B), assuming a normal strcpy.

Q20MCQ1 mark · -1/3· Easy

Consider an unordered list of N distinct integers. What is the minimum number of element comparisons required to find an integer in the list that is NOT the largest in the list?

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

Pick any two elements and compare them once. The smaller one cannot be the largest element of the list, since the other is bigger. Zero comparisons cannot work because no element is known to be non-maximal. Answer: (A) 1.

Concept: Read the question: any non-largest element is enough, not the largest itself. The trap is answering N - 1, the cost of finding the maximum.

Q21MCQ1 mark · -1/3· Easy

Consider the following statements about the use of backpatching in a compiler for intermediate code generation: (I) Backpatching can be used to generate code for Boolean expression in one pass. (II) Backpatching can be used to generate code for flow-of-control statements in one pass. Which ONE of the following options is CORRECT?

  1. (A)Only (I) is correct.
  2. (B)Only (II) is correct.
  3. (C)Both (I) and (II) are correct.
  4. (D)Neither (I) nor (II) is correct.
Answer: C - show solution

Backpatching keeps lists of jumps with unfilled targets (truelist, falselist, nextlist) and fills them in when the target label becomes known. This is exactly what lets a compiler generate code for Boolean expressions with short-circuit jumps and for flow-of-control statements (if, while) in a single pass. Both statements are correct. Answer: (C).

Concept: Backpatching exists to avoid a second pass over generated code; the textbook treatment applies it first to Boolean expressions and then to control flow.

Q22MCQ1 mark · -1/3· Moderate

Given the following syntax directed translation rules: Rule 1: R → AB {B.i = R.i - 1; A.i = B.i; R.i = A.i + 1;} Rule 2: P → CD {P.i = C.i + D.i; D.i = C.i + 2;} Rule 3: Q → EF {Q.i = E.i + F.i;} Which ONE is the CORRECT option among the following?

  1. (A)Rule 1 is S-attributed and L-attributed; Rule 2 is S-attributed and not L-attributed; Rule 3 is neither S-attributed nor L-attributed
  2. (B)Rule 1 is neither S-attributed nor L-attributed; Rule 2 is S-attributed and L-attributed; Rule 3 is S-attributed and L-attributed
  3. (C)Rule 1 is neither S-attributed nor L-attributed; Rule 2 is not S-attributed and is L-attributed; Rule 3 is S-attributed and L-attributed
  4. (D)Rule 1 is S-attributed and not L-attributed; Rule 2 is not S-attributed and is L-attributed; Rule 3 is S-attributed and L-attributed
Answer: C - show solution

Rule 1: A.i = B.i makes A's attribute depend on its right sibling B, which violates L-attribution; it also has inherited attributes, so it is not S-attributed. Neither. Rule 2: D.i = C.i + 2 is inherited from the left sibling (allowed in L-attributed, not in S-attributed); P.i is synthesized. So L-attributed, not S-attributed. Rule 3: only the head is computed from children: S-attributed and hence also L-attributed. Answer: (C).

Concept: S-attributed means only synthesized attributes. L-attributed allows inherited attributes that depend only on the parent and left siblings. Every S-attributed definition is L-attributed. The trap is missing the right-sibling dependency in Rule 1.

Q23MCQ1 mark · -1/3· Moderate

Consider a network that uses Ethernet and IPv4. Assume that IPv4 headers do not use any options field. Each Ethernet frame can carry a maximum of 1500 bytes in its data field. A UDP segment is transmitted. The payload (data) in the UDP segment is 7488 bytes. Which ONE of the following choices has the CORRECT total number of fragments transmitted and the size of the last fragment including IPv4 header?

  1. (A)5 fragments, 1488 bytes
  2. (B)6 fragments, 88 bytes
  3. (C)6 fragments, 108 bytes
  4. (D)6 fragments, 116 bytes
Answer: D - show solution

IP payload = UDP header 8 + data 7488 = 7496 bytes. With a 20-byte IP header and MTU 1500, each fragment carries at most 1480 bytes of payload (a multiple of 8, so valid). 7496 = 5 x 1480 + 96, so there are 5 full fragments and a 6th carrying 96 bytes. Last fragment size = 96 + 20 = 116 bytes. Answer: (D) 6 fragments, 116 bytes.

Concept: Fragmentation splits the whole IP payload, which includes the UDP header. Forgetting the 8-byte UDP header gives 88 bytes of payload and the trap answers 88 or 108.

Q24MCQ1 mark · -1/3· Easy

Which ONE of the following languages is accepted by a deterministic pushdown automaton?

  1. (A)Any regular language.
  2. (B)Any context-free language.
  3. (C)Any language accepted by a non-deterministic pushdown automaton.
  4. (D)Any decidable language.
Answer: A - show solution

Every regular language is accepted by a DFA, and a DFA is a DPDA that never uses its stack, so (A) holds. DPDAs accept only the deterministic CFLs, a proper subset of CFLs (for example even-length palindromes are not deterministic), so (B) and (C) fail. Decidable languages such as aⁿbⁿcⁿ are not even context-free, so (D) fails. Answer: (A).

Concept: Hierarchy: regular ⊂ DCFL ⊂ CFL ⊂ decidable. Unlike finite automata, nondeterministic PDAs are strictly more powerful than deterministic ones.

Q25MCQ1 mark · -1/3· Easy

Let G1, G2 be Context Free Grammars (CFGs) and R be a regular expression. For a grammar G, let L(G) denote the language generated by G. Which ONE among the following questions is decidable?

  1. (A)Is L(G1) = L(G2)?
  2. (B)Is L(G1) ∩ L(G2) = ∅?
  3. (C)Is L(G1) = L(R)?
  4. (D)Is L(G1) = ∅?
Answer: D - show solution

Emptiness of a CFG is decidable: mark generating variables bottom-up and check whether the start symbol is generating. Equivalence of two CFGs, emptiness of the intersection of two CFLs and equality of a CFL with a regular language are all undecidable (the last includes L(G) = Σ*, which is undecidable). Answer: (D).

Concept: For CFLs, membership, emptiness and finiteness are decidable; equivalence, universality, intersection-emptiness and ambiguity are not. The trap is (C): comparing with a regular language does not rescue equivalence.

Q26MCQ1 mark · -1/3· Moderate

Processes P1, P2, P3, P4 arrive in that order at times 0, 1, 2, and 8 milliseconds respectively, and have execution times of 10, 13, 6, and 9 milliseconds respectively. Shortest Remaining Time First (SRTF) algorithm is used as the CPU scheduling policy. Ignore context switching times. Which ONE of the following correctly gives the average turnaround time of the four processes in milliseconds?

  1. (A)22
  2. (B)15
  3. (C)37
  4. (D)19
Answer: D - show solution

t=0 P1 starts. t=1 P2 (13) arrives; P1 has 9 left, continues. t=2 P3 (6) arrives; P1 has 8 left, so P3 preempts and runs 2-8. t=8 P4 (9) arrives; remaining P1 8, P2 13, P4 9, so P1 runs 8-16. Then P4 16-25, P2 25-38. Turnaround: P1 16, P2 38-1 = 37, P3 8-2 = 6, P4 25-8 = 17. Average = 76/4 = 19 ms. Answer: (D) 19.

Concept: SRTF re-decides at every arrival using remaining time. The trap is using original burst times, or forgetting to subtract arrival times; 37 is P2's turnaround alone.

Q27MSQ1 mark · no negative· Moderate

An audit of a banking transactions system has found that on an earlier occasion, two joint holders of account A attempted simultaneous transfers of Rs. 10000 each from account A to account B. Both transactions read the same value, Rs. 11000, as the initial balance in A and were allowed to go through. B was credited Rs. 10000 twice. A was debited only once and ended up with a balance of Rs. 1000. Which of the following properties is/are certain to have been violated by the system?

  1. (A)Atomicity
  2. (B)Consistency
  3. (C)Isolation
  4. (D)Durability
Answer: B, C - show solution

Both transactions read A = 11000 before either wrote, and one debit overwrote the other: a lost update, so the interleaving was not equivalent to any serial order and Isolation was violated. The database ended with Rs. 20000 credited but only Rs. 10000 debited, so the invariant that transfers preserve total money broke: Consistency was violated (serially, the second transfer would have been refused for insufficient funds). Each transaction did all its own writes and the results persisted, so Atomicity and Durability are not certainly violated. Answer: (B) and (C).

Concept: Lost-update anomaly: a concurrency (isolation) failure that produces an inconsistent state. The trap is choosing atomicity because money went missing; each transaction itself completed fully.

Q28MSQ1 mark · no negative· Easy

Which of the following is/are part of an Instruction Set Architecture of a processor?

  1. (A)The size of the cache memory
  2. (B)The clock frequency of the processor
  3. (C)The number of cache memory levels
  4. (D)The total number of registers
Answer: D - show solution

The ISA is the programmer-visible contract: instructions, addressing modes, data types and the architectural registers. The total number of registers is part of it. Cache size, number of cache levels and clock frequency are implementation (microarchitecture) choices invisible to the instruction set and can differ between processors with the same ISA. Answer: (D).

Concept: Separate architecture from organization. The trap is treating performance features like caches or clock speed as part of the ISA.

Q29MSQ1 mark · no negative· Moderate

Which of the following statements regarding Breadth First Search (BFS) and Depth First Search (DFS) on an undirected simple graph G is/are TRUE?

  1. (A)A DFS tree of G is a Shortest Path tree of G.
  2. (B)Every non-tree edge of G with respect to a DFS tree is a forward/back edge.
  3. (C)If (u, v) is a non-tree edge of G with respect to a BFS tree, then the distances from the source vertex s to u and v in the BFS tree are within ±1 of each other.
  4. (D)Both BFS and DFS can be used to find the connected components of G.
Answer: B, C, D - show solution

(A) False: in a triangle s-a-b, DFS may go s-a-b, giving b depth 2 though its distance is 1. (B) True: in an undirected DFS there are no cross edges; every non-tree edge joins an ancestor and a descendant. (C) True: for any edge (u, v), BFS levels satisfy |d(u) - d(v)| ≤ 1, otherwise the farther vertex would have been discovered earlier. (D) True: repeatedly starting either traversal from an unvisited vertex labels components. Answer: (B), (C), (D).

Concept: Key edge properties: undirected DFS has only tree and back edges; BFS non-tree edges join the same or adjacent levels. Only BFS gives shortest paths in unweighted graphs.

Q30MSQ1 mark · no negative· Moderate

Consider the two lists List I and List II given below: List I: (i) Context free languages, (ii) Recursive languages, (iii) Regular languages List II: (a) Closed under union, (b) Not closed under complementation, (c) Closed under intersection For matching of items in List I with those in List II, which of the following option(s) is/are CORRECT?

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

CFLs: closed under union, not closed under complementation, not closed under intersection. Recursive languages: closed under union, intersection and complementation. Regular languages: closed under all three. (A) fails: recursive languages are closed under complement. (B) holds: CFL-(b), recursive-(a), regular-(c). (C) holds: CFL-(b), recursive-(c), regular-(a). (D) fails: regular languages are closed under complement. Answer: (B) and (C).

Concept: Since several pairings are true, check each pair independently. CFLs fail complement and intersection; recursive and regular classes are closed under all Boolean operations.

Q31MSQ1 mark · no negative· Easy

Consider the following logic circuit. Inputs X and Y feed three gates: a NAND gate with inputs X and Y; a NOT gate with input X; and an AND gate with inputs X and NOT Y (Y passes through an inverter). The outputs of these three gates feed a 3-input OR gate whose output is F. Which is/are the CORRECT option(s) for the output function F?

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

F = (XY)' + X' + XY' = X' + Y' + X' + XY'. Since XY' is absorbed by Y', F = X' + Y' = (XY)'. (A) (XY)' = X' + Y': equal. (B) X' + Y' + XY' = X' + Y': equal. (C) is the unsimplified circuit expression: equal. (D) X + Y' is 0 at X=0, Y=1 while F = 1 there: not equal. Answer: (A), (B), (C).

Concept: Read the gate outputs, OR them, then simplify with De Morgan and absorption. Several algebraically different forms can be equal; check each against the simplified function.

Q32NAT1 mark · no negative· Moderate

The following two signed 2's complement numbers (multiplicand M and multiplier Q) are being multiplied using Booth's algorithm: M: 1100 1101 1110 1101 and Q: 1010 0100 1010 1010 The total number of addition and subtraction operations to be performed is ___________. (Answer in integer)

Answer: 13 - show solution

Booth's algorithm scans multiplier bit pairs (Qi, Qi-1) from the LSB with Q-1 = 0: 10 means subtract M, 01 means add M, 00 and 11 do nothing. Q = 1010 0100 1010 1010. From the LSB the bits are 0,1,0,1,0,1,0,1,0,0,1,0,0,1,0,1. Pairs for i = 0..15: 00, 10, 01, 10, 01, 10, 01, 10, 01, 00, 10, 01, 00, 10, 01, 10. Non-00/11 pairs: 8 (i = 1 to 8) + 2 (i = 10, 11) + 3 (i = 13, 14, 15) = 13. The multiplicand M does not affect the count. Answer: 13.

Concept: Count bit transitions in the multiplier with an implicit 0 appended at the right. Alternating bit patterns are Booth's worst case. The trap is counting operations on M, or forgetting Q-1.

Q33NAT1 mark · no negative· Easy

The output of the given C code segment is ________. (Answer in integer)

int x=126,y=105;
do {
    if(x>y) x=x-y;
    else y=y-x;
} while(x!=y);
printf("%d",x);
Answer: 21 - show solution

This is the subtraction form of Euclid's algorithm, ending at gcd(x, y). Trace: (126,105) -> (21,105) -> (21,84) -> (21,63) -> (21,42) -> (21,21), stop. gcd(126, 105) = 21. Answer: 21.

Concept: Recognising repeated subtraction as Euclid's GCD saves tracing. The do-while runs its body at least once, harmless here since x ≠ y initially.

Q34NAT1 mark · no negative· Easy

In a 4-bit ripple counter, if the period of the waveform at the last flip-flop is 64 microseconds, then the frequency of the ripple counter in kHz is ________. (Answer in integer)

Answer: 250 - show solution

Each flip-flop in a ripple counter divides the frequency by 2, so the 4th flip-flop output has frequency f/16. Its period is 64 µs, so its frequency is 1/64 µs = 15.625 kHz. Clock frequency f = 16 x 15.625 = 250 kHz. Answer: 250.

Concept: An n-bit ripple counter is a divide-by-2ⁿ chain. The trap is reporting the last stage's 15.625 kHz instead of the counter's clock frequency.

Q35NAT1 mark · no negative· Easy

Suppose the values 10, -4, 15, 30, 20, 5, 60, 19 are inserted in that order into an initially empty binary search tree. Let T be the resulting binary search tree. The number of edges in the path from the node containing 19 to the root node of T is ___________. (Answer in integer)

Answer: 4 - show solution

10 is the root. -4 goes left of 10, 15 right of 10, 30 right of 15, 20 left of 30, 5 right of -4, 60 right of 30, 19 left of 20. Path from 19 to the root: 19 - 20 - 30 - 15 - 10, which has 4 edges. Answer: 4.

Concept: Insert in order, comparing from the root each time. Count edges, not nodes: 5 nodes on the path means 4 edges.

Q36MCQ2 marks · -2/3· Easy

Suppose we are transmitting frames between two nodes using Stop-and-Wait protocol. The frame size is 3000 bits. The transmission rate of the channel is 2000 bps (bits/second) and the propagation delay between the two nodes is 100 milliseconds. Assume that the processing times at the source and destination are negligible. Also, assume that the size of the acknowledgement packet is negligible. Which ONE of the following most accurately gives the channel utilization for the above scenario in percentage?

  1. (A)88.23
  2. (B)93.75
  3. (C)85.44
  4. (D)66.67
Answer: A - show solution

Transmission time = 3000 / 2000 = 1.5 s. Propagation delay = 0.1 s, so round trip = 0.2 s (ACK transmission negligible). Utilization = 1.5 / (1.5 + 0.2) = 1.5 / 1.7 = 0.88235, i.e. 88.23%. Answer: (A) 88.23.

Concept: Stop-and-wait efficiency = Tt / (Tt + 2Tp). The trap is using one-way delay, which gives 93.75%.

Q37MCQ2 marks · -2/3· Moderate

Let G be an edge-weighted undirected graph with positive edge weights. Suppose a positive constant α is added to the weight of every edge. Which ONE of the following statements is TRUE about the minimum spanning trees (MSTs) and shortest paths (SPs) in G before and after the edge weight update?

  1. (A)Every MST remains an MST, and every SP remains an SP.
  2. (B)MSTs need not remain MSTs, and every SP remains an SP.
  3. (C)Every MST remains an MST, and SPs need not remain SPs.
  4. (D)MSTs need not remain MSTs, and SPs need not remain SPs.
Answer: C - show solution

Every spanning tree has exactly n - 1 edges, so each tree's weight rises by (n - 1)α and the ranking of trees is unchanged: every MST stays an MST. A path with k edges rises by kα, so paths with more edges are penalized more. Example: s-t direct weight 3, s-a-t with weights 1 and 1. Before, s-a-t (2) is shortest; after adding 2, direct = 5 and s-a-t = 6. SPs need not remain SPs. Answer: (C).

Concept: MSTs depend only on the relative order of edge weights; shortest paths depend on sums over paths of varying length. Multiplying all weights by a positive constant would preserve both.

Q38MCQ2 marks · -2/3· Moderate

A meld operation on two instances of a data structure combines them into one single instance of the same data structure. Consider the following data structures: P: Unsorted doubly linked list with pointers to the head node and tail node of the list. Q: Min-heap implemented using an array. R: Binary Search Tree. Which ONE of the following options gives the worst-case time complexities for meld operation on instances of size n of these data structures?

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

P: link the first list's tail to the second list's head and update the tail pointer: Θ(1). Q: concatenate the two arrays and run bottom-up build-heap on 2n elements: Θ(n); any method must at least move n elements. R: in-order traverse both trees to get two sorted lists (Θ(n)), merge them (Θ(n)) and build a BST from the sorted list (Θ(n)); every node must be visited, so Θ(n). Answer: (A).

Concept: Build-heap is linear, not n log n, and sorted sequences let a BST be rebuilt in linear time. The traps are repeated insertion costs (n log n or n²).

Q39MCQ2 marks · -2/3· Easy

For a direct-mapped cache, 4 bits are used for the tag field and 12 bits are used to index into a cache block. The size of each cache block is one byte. Assume that there is no other information stored for each cache block. Which ONE of the following is the CORRECT option for the sizes of the main memory and the cache memory in this system (byte addressable), respectively?

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

Block size is 1 byte, so there are no offset bits. Address = tag 4 + index 12 = 16 bits, so main memory = 2¹⁶ bytes = 64 KB. The cache has 2¹² blocks of 1 byte = 4 KB (tags are not counted as no other information is stored). Answer: (A) 64 KB and 4 KB.

Concept: Direct-mapped address split: tag | index | offset. With one-byte blocks the offset is 0 bits, a detail that is easy to overlook.

Q40MCQ2 marks · -2/3· Hard

Given a Context-Free Grammar G as follows: S → Aa | bAc | dc | bda A → d Which ONE of the following statements is TRUE?

  1. (A)G is neither LALR(1) nor SLR(1)
  2. (B)G is CLR(1), not LALR(1)
  3. (C)G is LALR(1), not SLR(1)
  4. (D)G is LALR(1), also SLR(1)
Answer: C - show solution

FOLLOW(A) = {a, c}. From I0 on d: {S → d.c, A → d.}. SLR reduces A → d on FOLLOW(A), including c, while S → d.c shifts c: shift-reduce conflict, so not SLR(1). In LR(1) this item is A → d. with lookahead a only, so no conflict. After b then d: {S → bd.a, A → d.} with LR(1) lookahead c, while shift is on a: no conflict (SLR would conflict on a). The two d-states have different cores, so LALR merging joins nothing and introduces no conflict. G is LALR(1) but not SLR(1). Answer: (C).

Concept: Classic grammar separating SLR from LALR: FOLLOW sets are too coarse, while LR(1) lookaheads are context-specific. Check that LALR merging only combines states with identical cores.

Q41MCQ2 marks · -2/3· Moderate

An array A of length n with distinct elements is said to be bitonic if there is an index 1 ≤ i ≤ n such that A[1..i] is sorted in the non-decreasing order and A[i + 1..n] is sorted in the non-increasing order. Which ONE of the following represents the best possible asymptotic bound for the worst-case number of comparisons by an algorithm that searches for an element in a bitonic array A?

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

Find the peak by binary search: compare A[mid] with A[mid+1]; if increasing, the peak is to the right, else at or to the left. This takes O(log n). Then binary search the increasing part and the decreasing part separately, O(log n) each. Total O(log n). A lower bound of Ω(log n) holds because a sorted array is a special bitonic array. Answer: (D) Θ(log n).

Concept: Decompose into peak-finding plus two ordinary binary searches. The trap is (C), assuming nested binary searches.

Q42MSQ2 marks · no negative· Moderate

Let ℱ be the set of all functions from {1, ..., n} to {0, 1}. Define the binary relation ≼ on ℱ as follows: ∀f, g ∈ ℱ, f ≼ g if and only if ∀x ∈ {1, ..., n}, f(x) ≤ g(x), where 0 ≤ 1. Which of the following statement(s) is/are TRUE?

  1. (A)≼ is a symmetric relation
  2. (B)(ℱ, ≼) is a partial order
  3. (C)(ℱ, ≼) is a lattice
  4. (D)≼ is an equivalence relation
Answer: B, C - show solution

≼ is the componentwise order on n-bit vectors. Reflexive (f(x) ≤ f(x)), antisymmetric (f ≤ g and g ≤ f pointwise gives f = g) and transitive: a partial order. Meet and join are the pointwise min (AND) and max (OR), which are in ℱ, so it is a lattice (isomorphic to the subset lattice of {1..n}). It is not symmetric: the all-0 function ≼ the all-1 function but not conversely, hence also not an equivalence relation. Answer: (B) and (C).

Concept: Functions to {0,1} are characteristic vectors of subsets, and ≼ is set inclusion, the Boolean lattice. A partial order is symmetric only on a trivial set.

Q43MSQ2 marks · no negative· Moderate

Given the following Karnaugh Map for a Boolean function F(w, x, y, z) (rows wx = 00, 01, 11, 10; columns yz = 00, 01, 11, 10): wx\yz 00 01 11 10 00 1 0 0 1 01 0 1 1 0 11 0 1 1 0 10 1 0 0 1 Which one or more of the following Boolean expression(s) represent(s) F?

  1. (A)w'x'y'z' + wx'y'z' + w'x'yz' + wx'yz' + xz
  2. (B)w'x'y'z' + w'x'yz' + wx'yz + xz
  3. (C)w'x'y'z' + wx'y'z' + wx'y'z + xz
  4. (D)x'z' + xz
Answer: A, D - show solution

The four corner cells (x = 0, z = 0) are 1: group x'z'. The central 2x2 block (x = 1, z = 1) is 1: group xz. All other cells are 0, so F = x'z' + xz. (A) the four minterms are exactly the corners (x'z') plus xz: equal. (B) contains wx'yz, which has x = 0, z = 1, a 0 cell: wrong. (C) contains wx'y'z, also x = 0, z = 1: wrong. (D) is the minimal form. Answer: (A) and (D).

Concept: K-maps wrap around, so the four corners form one group. A sum is correct only if it covers every 1 and no 0; a single stray minterm on a 0 cell disqualifies it.

Q44MSQ2 marks · no negative· Moderate

Consider a system of linear equations PX = Q where P ∈ ℝ^(3×3) and Q ∈ ℝ^(3×1). Suppose P has an LU decomposition, P = LU, where L = [[1, 0, 0], [l21, 1, 0], [l31, l32, 1]] and U = [[u11, u12, u13], [0, u22, u23], [0, 0, u33]]. Which of the following statement(s) is/are TRUE?

  1. (A)The system PX = Q can be solved by first solving LY = Q and then UX = Y.
  2. (B)If P is invertible, then both L and U are invertible.
  3. (C)If P is singular, then at least one of the diagonal elements of U is zero.
  4. (D)If P is symmetric, then both L and U are symmetric.
Answer: A, B, C - show solution

(A) LUX = Q: put Y = UX, solve LY = Q by forward substitution, then UX = Y by back substitution: true. det L = 1 and det U = u11 u22 u33, so det P = u11 u22 u33. (B) P invertible gives det U ≠ 0, and L is always invertible: true. (C) P singular gives u11 u22 u33 = 0, so some uii = 0: true. (D) false: triangular matrices with nonzero off-diagonal entries are not symmetric; for symmetric P one gets P = LDLᵀ, not symmetric L and U. Answer: (A), (B), (C).

Concept: The determinant of a triangular matrix is the product of its diagonal, which links P's invertibility to U's pivots. Symmetry of P gives U = DLᵀ, not symmetric factors.

Q45MSQ2 marks · no negative· Moderate

Consider a stack data structure into which we can PUSH and POP records. Assume that each record pushed in the stack has a positive integer key and that all keys are distinct. We wish to augment the stack data structure with an O(1) time MIN operation that returns a pointer to the record with smallest key present in the stack 1) without deleting the corresponding record, and 2) without increasing the complexities of the standard stack operations. Which one or more of the following approach(es) can achieve it?

  1. (A)Keep with every record in the stack, a pointer to the record with the smallest key below it.
  2. (B)Keep a pointer to the record with the smallest key in the stack.
  3. (C)Keep an auxiliary array in which the key values of the records in the stack are maintained in sorted order.
  4. (D)Keep a Min-Heap in which the key values of the records in the stack are maintained.
Answer: A - show solution

(A) On PUSH, store with the new record a pointer to the minimum among the records below it (computed in O(1) from the previous top's own value and pointer). MIN compares the top with its stored pointer: O(1), and POP needs no work. Works. (B) A single global pointer cannot be restored in O(1) after the minimum is popped. Fails. (C) Inserting into a sorted array costs O(n) per PUSH. Fails. (D) Heap insert and delete cost O(log n), raising PUSH/POP above O(1). Fails. Answer: (A).

Concept: The min-stack technique: each stack level remembers the minimum of everything at or below it, so the answer is restored automatically on pop. The trap is (B), which breaks on popping the minimum.

Q46MSQ2 marks · no negative· Moderate

Consider the following relational schema along with all the functional dependencies that hold on them. R1(A, B, C, D, E): {D → E, EA → B, EB → C} R2(A, B, C, D): {A → D, A → B, C → A} Which of the following statement(s) is/are TRUE?

  1. (A)R1 is in 3NF
  2. (B)R2 is in 3NF
  3. (C)R1 is NOT in 3NF
  4. (D)R2 is NOT in 3NF
Answer: C, D - show solution

R1: A and D appear on no right side, so both are in every key. AD+ = {A, D, E, B, C}, so AD is the only candidate key and the prime attributes are A, D. D → E: D is not a superkey and E is not prime, so R1 is not in 3NF. R2: C appears on no right side; C+ = {C, A, D, B}, so C is the only key and C is the only prime attribute. A → D: A is not a superkey and D is not prime (a transitive dependency C → A → D), so R2 is not in 3NF. Answer: (C) and (D).

Concept: 3NF requires every nontrivial X → Y to have X a superkey or Y prime. Find keys first using attributes that never appear on a right side; both schemas contain a dependency from a non-key to a non-prime attribute.

Q47MSQ2 marks · no negative· Hard

Consider a demand paging system with three frames, and the following page reference string: 1 2 3 4 5 4 1 6 4 5 1 3 2. The contents of the frames are as follows initially and after each reference (from left to right): Reference: - 1* 2* 3* 4* 5* 4 1 6* 4 5 1* 3* 2* Frame 1: - 1 1 1 1 1 1 1 6 6 6 6 6 2 Frame 2: - - 2 2 4 4 4 4 4 4 4 1 1 1 Frame 3: - - - 3 3 5 5 5 5 5 5 5 3 3 The *-marked references cause page faults (replacements once the frames are full). Which one or more of the following could be the page replacement policy/policies in use?

  1. (A)Least Recently Used page replacement policy
  2. (B)Least Frequently Used page replacement policy
  3. (C)Most Frequently Used page replacement policy
  4. (D)Optimal page replacement policy
Answer: D - show solution

At reference 4, frames hold 1, 2, 3 and page 2 is evicted. LRU would evict 1 (least recently used): LRU fails. Optimal: next uses are 1 at position 7, 3 at 12, 2 at 13, so evict 2: matches. At 5, frames 1, 4, 3: next uses 4 at 6, 1 at 7, 3 at 12, evict 3: matches. At 6, frames 1, 4, 5: next uses 4 at 9, 5 at 10, 1 at 11, evict 1: matches. The last three faults find no resident page used again, so any choice is optimal. LFU: at reference 6, page 5 has been used once while 1 and 4 twice, so LFU evicts 5, not 1: fails. MFU: at reference 4 all counts are 1 and the usual FIFO tie-break evicts 1, not 2; with cumulative counts it also evicts 1 at reference 3 instead of 5: fails. Answer: (D).

Concept: Check each policy at the first fault where it would decide differently. Optimal looks forward and evicts the page used farthest in the future. The trap is accepting a policy only through arbitrary tie-breaking.

Q48MSQ2 marks · no negative· Moderate

P = {P1, P2, P3, P4} consists of all active processes in an operating system. R = {R1, R2, R3, R4} consists of single instances of distinct types of resources in the system. The resource allocation graph has the following assignment and claim edges. Assignment edges: R1 → P1, R2 → P2, R3 → P3, R4 → P4 (the assignment edge R1 → P1 means resource R1 is assigned to process P1, and so on for others). Claim edges: P1 → R2, P2 → R3, P3 → R1, P2 → R4, P4 → R2 (the claim edge P1 → R2 means process P1 is waiting for resource R2, and so on for others). Which of the following statement(s) is/are CORRECT?

  1. (A)Aborting P1 makes the system deadlock free.
  2. (B)Aborting P3 makes the system deadlock free.
  3. (C)Aborting P2 makes the system deadlock free.
  4. (D)Aborting P1 and P4 makes the system deadlock free.
Answer: C, D - show solution

With single-instance resources, use the wait-for graph: P1 → P2 (R2), P2 → P3 (R3), P3 → P1 (R1), P2 → P4 (R4), P4 → P2 (R2). Cycles: P1-P2-P3-P1 and P2-P4-P2. (A) Aborting P1 leaves the P2-P4 cycle. (B) Aborting P3 leaves the P2-P4 cycle. (C) P2 lies on both cycles; aborting it releases R2, so P1 and P4 can finish, then P3. Deadlock free. (D) Aborting P1 and P4 frees R1 and R4: P3 gets R1 and finishes, releasing R3, then P2 finishes. Deadlock free. Answer: (C) and (D).

Concept: With one instance per resource, a cycle means deadlock. To recover, every cycle must be broken; pick a process common to all cycles or a set covering them.

Q49MSQ2 marks · no negative· Moderate

Three floating point numbers X, Y, and Z are stored in three registers RX, RY, and RZ, respectively in IEEE 754 single precision format as given below in hexadecimal: RX = 0xC1100000, RY = 0x40C00000, and RZ = 0x41400000. Which of the following option(s) is/are CORRECT?

  1. (A)4(X + Y) + Z = 0
  2. (B)2Y - Z = 0
  3. (C)4X + 3Z = 0
  4. (D)X + Y + Z = 0
Answer: A, B, C - show solution

0xC1100000 = 1 10000010 00100...: sign -, exponent 130 - 127 = 3, mantissa 1.001₂ = 1.125, so X = -9. 0x40C00000 = 0 10000001 100...: exponent 2, mantissa 1.5, so Y = 6. 0x41400000 = 0 10000010 100...: exponent 3, mantissa 1.5, so Z = 12. (A) 4(-3) + 12 = 0: true. (B) 12 - 12 = 0: true. (C) -36 + 36 = 0: true. (D) -9 + 6 + 12 = 9: false. Answer: (A), (B), (C).

Concept: Decode by splitting into sign (1), biased exponent (8, bias 127) and fraction (23) with the hidden leading 1. Forgetting the hidden bit or the bias is the usual error.

Q50MSQ2 marks · no negative· Moderate

Which of the following Boolean algebraic equation(s) is/are CORRECT?

  1. (A)A'BC + AB'C' + A'B'C' + AB'C + ABC = BC + B'C' + A'B'
  2. (B)AB + A'C + BC = AB + A'C
  3. (C)(A + C)(A' + B) = AB + A'C
  4. (D)[(A + B' + D')(C + D)(A' + C + D)(A + B + D')]' = A'D + C'D'
Answer: B, C, D - show solution

(A) LHS minterms (ABC) are 011, 100, 000, 101, 111 = {0, 3, 4, 5, 7}. RHS: BC = {3, 7}, B'C' = {0, 4}, A'B' = {0, 1}, giving {0, 1, 3, 4, 7}: it includes 1 and misses 5. False. (B) Consensus theorem: BC is redundant. True. (C) (A + C)(A' + B) = AA' + AB + A'C + BC = AB + A'C + BC = AB + A'C. True. (D) By De Morgan, the complement of the product is the sum of complements: A'BD + C'D' + AC'D' + A'B'D = A'D(B + B') + C'D'(1 + A) = A'D + C'D'. True. Answer: (B), (C), (D).

Concept: Tests the consensus theorem, product-of-sums expansion and De Morgan over a whole product. Comparing minterm sets is the safest check for (A)-type claims.

Q51MSQ2 marks · no negative· Hard

Consider two grammars G1 and G2 with the production rules given below: G1: S → if E then S | if E then S else S | a E → b G2: S → if E then S | M M → if E then M else S | c E → b where if, then, else, a, b, c are the terminals. Which of the following option(s) is/are CORRECT?

  1. (A)G1 is not LL(1) and G2 is LL(1).
  2. (B)G1 is LL(1) and G2 is not LL(1).
  3. (C)G1 and G2 are not LL(1).
  4. (D)G1 and G2 are ambiguous.
Answer: C, D - show solution

Not LL(1): in G1 two S-productions begin with "if"; in G2, S → if E then S and S → M both have "if" in FIRST (M → if ...). So neither is LL(1). G1 is the classic dangling-else grammar: "if b then if b then a else a" has two parse trees. G2 is also ambiguous because the else-part of M is an unrestricted S. M derives "if b then c else if b then c". Then w = "if b then if b then c else if b then c else c" parses as S → if b then S with S = M = if b then c else (if b then c else c), and also as S → M = if b then M' else c with M' = "if b then c else if b then c". Answer: (C) and (D).

Concept: Any ambiguous grammar is not LL(1), and common prefixes also break LL(1). G2 looks like the standard matched/unmatched fix, but allowing an unmatched S after else reintroduces ambiguity.

Q52MSQ2 marks · no negative· Moderate

Let Σ = {a, b, c}. For x ∈ Σ*, and α ∈ Σ, let #α(x) denote the number of occurrences of α in x. Which one or more of the following option(s) define(s) regular language(s)?

  1. (A){aᵐbⁿ | m, n ≥ 0}
  2. (B){a, b}* ∩ {aᵐbⁿcᵐ⁻ⁿ | m ≥ n ≥ 0}
  3. (C){w | w ∈ {a, b}*, #a(w) ≡ 2 (mod 7), and #b(w) ≡ 3 (mod 9)}
  4. (D){w | w ∈ {a, b}*, #a(w) ≡ 2 (mod 7), and #a(w) = #b(w)}
Answer: A, C - show solution

(A) = a*b*: regular. (B) Intersecting with {a, b}* forbids c, so m - n = 0 and the language is {aⁿbⁿ | n ≥ 0}: not regular (pumping lemma). (C) A product DFA tracking #a mod 7 and #b mod 9 (63 states) accepts it: regular. (D) Requires #a = #b with no bound, an unbounded comparison: intersecting with a*b* gives {aⁿbⁿ | n ≡ 2 mod 7}, not regular, so (D) is not regular. Answer: (A) and (C).

Concept: Modular counting needs finitely many states; equality of two unbounded counts does not. The trap in (B) is that the intersection forces m = n, leaving aⁿbⁿ.

Q53MSQ2 marks · no negative· Moderate

Consider the database transactions T1 and T2, and data items X and Y. T1: R1(X), W1(Y), R1(X), W1(X), COMMIT(T1) T2: W2(X), W2(Y), COMMIT(T2) Which of the schedule(s) is/are conflict serializable?

  1. (A)R1(X), W2(X), W1(Y), W2(Y), R1(X), W1(X), COMMIT(T2), COMMIT(T1)
  2. (B)W2(X), R1(X), W2(Y), W1(Y), R1(X), COMMIT(T2), W1(X), COMMIT(T1)
  3. (C)R1(X), W1(Y), W2(X), W2(Y), R1(X), W1(X), COMMIT(T1), COMMIT(T2)
  4. (D)W2(X), R1(X), W1(Y), W2(Y), R1(X), COMMIT(T2), W1(X), COMMIT(T1)
Answer: B - show solution

Conflicting pairs: T1's R1(X), R1(X), W1(X) with W2(X); W1(Y) with W2(Y). (A) R1(X) before W2(X): T1→T2; second R1(X) after W2(X): T2→T1. Cycle, not serializable. (B) W2(X) before both R1(X) and W1(X), W2(Y) before W1(Y): all edges T2→T1. Acyclic, equivalent to T2, T1. (C) R1(X) before W2(X): T1→T2; second R1(X) after W2(X): T2→T1. Cycle. (D) W2(X) before R1(X): T2→T1; W1(Y) before W2(Y): T1→T2. Cycle. Answer: (B).

Concept: Build the precedence graph from every conflicting pair (same item, different transactions, at least one write). The repeated R1(X) is the trap: a write by T2 between T1's two reads creates the back edge.

Q54MSQ2 marks · no negative· Easy

Consider the following relational schema: Students (rollno: integer, name: string, age: integer, cgpa: real) Courses (courseno: integer, cname: string, credits: integer) Enrolled (rollno: integer, courseno: integer, grade: string) Which of the following options is/are correct SQL query/queries to retrieve the names of the students enrolled in course number (i.e., courseno) 1470?

  1. (A)SELECT S.name FROM Students S WHERE EXISTS (SELECT * FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno);
  2. (B)SELECT S.name FROM Students S WHERE SIZEOF (SELECT * FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno) > 0;
  3. (C)SELECT S.name FROM Students S WHERE 0 < (SELECT COUNT(*) FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno);
  4. (D)SELECT S.name FROM Students S NATURAL JOIN Enrolled E WHERE E.courseno = 1470;
Answer: A, C, D - show solution

(A) The correlated EXISTS subquery is true exactly when the student has an Enrolled row for 1470: correct. (B) SIZEOF is not an SQL function, so the query is invalid. (C) COUNT(*) of matching Enrolled rows greater than 0: correct. (D) Students and Enrolled share only rollno, so the natural join pairs each student with their enrollments; filtering courseno = 1470 returns the right names: correct. Answer: (A), (C), (D).

Concept: Several SQL forms express "exists a matching row": EXISTS, COUNT > 0, or a join. Check that a natural join uses only the intended common column, and spot non-standard functions.

Q55NAT2 marks · no negative· Moderate

Given a computing system with two levels of cache (L1 and L2) and a main memory. The first level (L1) cache access time is 1 nanosecond (ns) and the "hit rate" for L1 cache is 90% while the processor is accessing the data from L1 cache. Whereas, for the second level (L2) cache, the "hit rate" is 80% and the "miss penalty" for transferring data from L2 cache to L1 cache is 10 ns. The "miss penalty" for the data to be transferred from main memory to L2 cache is 100 ns. Then the average memory access time in this system in nanoseconds is ___________ . (rounded off to one decimal place) A 5-stage instruction pipeline has stage delays of 180, 250, 150, 170, and 250, respectively, in nanoseconds. The delay of an inter-stage latch is 10 nanoseconds.

Answer: 4 - show solution

AMAT = L1 time + L1 miss rate x (L1 miss penalty), where L1 miss penalty = L2 time + L2 miss rate x (L2 miss penalty). L1 miss penalty = 10 + 0.2 x 100 = 30 ns. AMAT = 1 + 0.1 x 30 = 4 ns. Answer: 4.0.

Concept: Nested miss-penalty formula with local hit rates. The trap is multiplying absolute times for every level or treating 80% as a global hit rate.

Q56NAT2 marks · no negative· Easy

A 5-stage instruction pipeline has stage delays of 180, 250, 150, 170, and 250, respectively, in nanoseconds. The delay of an inter-stage latch is 10 nanoseconds. Assume that there are no pipeline stalls due to branches and other hazards. The time taken to process 1000 instructions in microseconds is __________. (rounded off to two decimal places)

Answer: 260.2 to 261.2 - show solution

Clock cycle = max stage delay + latch delay = 250 + 10 = 260 ns. For k = 5 stages and n = 1000 instructions, cycles = k + n - 1 = 1004. Time = 1004 x 260 ns = 261040 ns = 261.04 µs. The accepted range 260.2 to 261.2 covers this; ignoring the pipeline fill (1000 x 260 = 260.00 µs) falls outside it. Answer: 261.04.

Concept: Pipeline cycle time is set by the slowest stage plus latch overhead, and n instructions need k + n - 1 cycles. Forgetting the latch delay or the fill cycles is the trap.

Q57NAT2 marks · no negative· Hard

In a B+-tree where each node can hold at most four key values, a root to leaf path consists of the following nodes: A = (49, 77, 83, -), B = (7, 19, 33, 44), C = (20*, 22*, 25*, 26*). The *-marked keys signify that these are data entries in a leaf. Assume that a pointer between keys k1 and k2 points to a subtree containing keys in [k1, k2), and that when a leaf is created, the smallest key in it is copied up into its parent. A record with key value 23 is inserted into the B+-tree. The smallest key value in the parent of the leaf that contains 25* is __________. (Answer in integer)

Answer: 33 - show solution

Leaf C is full, so inserting 23 splits {20, 22, 23, 25, 26} into two leaves, and the new leaf's smallest key (23 for a 2|3 split, 25 for a 3|2 split) is copied into B. B = (7, 19, 33, 44) is also full and becomes 5 keys, e.g. (7, 19, 23, 33, 44). An internal split pushes the middle key up to A: left node (7, 19), right node (33, 44), with 23 (or 25) moving to A. The leaf containing 25* covers keys from 23 (or 25) up to 33, so it hangs from the leftmost pointer of the right node (33, 44). Either split choice gives that parent, whose smallest key is 33. Answer: 33.

Concept: Leaf splits copy a key up, but internal splits move the middle key up without keeping it. The trap is assuming the separator stays in the leaf's parent, which would give 23 or 25.

Q58NAT2 marks · no negative· Moderate

A computer system supports a logical address space of 2³² bytes. It uses two-level hierarchical paging with a page size of 4096 bytes. A logical address is divided into a b-bit index to the outer page table, an offset within the page of the inner page table, and an offset within the desired page. Each entry of the inner page table uses eight bytes. All the pages in the system have the same size. The value of b is ___________. (Answer in integer)

Answer: 11 - show solution

Page offset = log2(4096) = 12 bits. One page of the inner page table holds 4096 / 8 = 512 entries, so the inner index is 9 bits. Outer index b = 32 - 12 - 9 = 11. Answer: 11.

Concept: Each inner page table occupies exactly one page, so its index width is log2(page size / entry size). The trap is assuming 4-byte entries, which gives 10.

Q59NAT2 marks · no negative· Moderate

Consider the following algorithm someAlgo that takes an undirected graph G as input. The output of someAlgo(T) for the tree T described below is ___________. (Answer in integer) The tree T (as drawn in the paper) has 14 vertices, labelled here A to N, and 13 edges: A-C, C-D, C-E, B-E, E-F, F-G, E-H, H-I, H-J, H-K, K-L, K-M, M-N.

someAlgo(G)
  1. Let v be any vertex in G. Run BFS on G starting at v.
     Let u be a vertex in G at maximum distance from v as given by the BFS.
  2. Run BFS on G again with u as the starting vertex.
     Let z be the vertex at maximum distance from u as given by the BFS.
  3. Output the distance between u and z in G.
Answer: 6 - show solution

Two BFS passes on a tree return its diameter: the first BFS ends at an endpoint of a longest path, the second measures that path. Longest paths here: N-M-K-H-E-F-G and N-M-K-H-E-C-A, each with 6 edges. Check: from E the farthest vertices are N (4 edges) and A, G, D (2 edges), so no path is longer than 4 + 2 = 6. Answer: 6.

Concept: Double BFS computes the diameter of a tree exactly (not of general graphs). Count edges along the longest path, not vertices.

Q60NAT2 marks · no negative· Moderate

Let Σ = {1, 2, 3, 4}. For x ∈ Σ*, let prod(x) be the product of symbols in x modulo 7. We take prod(ε) = 1, where ε is the null string. For example, prod(124) = (1 × 2 × 4) mod 7 = 1. Define L = {x ∈ Σ* | prod(x) = 2}. The number of states in a minimum state DFA for L is ___________. (Answer in integer)

Answer: 6 - show solution

Track prod(x) mod 7. Every symbol is nonzero mod 7 and 7 is prime, so the product is never 0 and the states are the residues 1 to 6. All are reachable: 3 generates the group (3, 2, 6, 4, 5, 1). Accept only residue 2. Any two residues r ≠ s are distinguishable: take y with r·prod(y) ≡ 2; then s·prod(y) ≢ 2. There is no dead state, since every residue can still reach 2. Minimum DFA: 6 states. Answer: 6.

Concept: Myhill-Nerode with a group structure: multiplication by a fixed symbol permutes the residues, so all reachable states stay distinguishable. The trap is counting 7 states, including an unreachable residue 0.

Q61NAT2 marks · no negative· Easy

An application executes 6.4 × 10⁸ number of instructions in 6.3 seconds. There are four types of instructions, the details of which are given in the table. The duration of a clock cycle in nanoseconds is _________. (rounded off to one decimal place) Instruction type CPI Number of instructions executed Branch 2 2.25 × 10⁸ Load 5 1.20 × 10⁸ Store 4 1.65 × 10⁸ Arithmetic 3 1.30 × 10⁸

Answer: 3 - show solution

Total cycles = (2 x 2.25 + 5 x 1.20 + 4 x 1.65 + 3 x 1.30) x 10⁸ = (4.5 + 6.0 + 6.6 + 3.9) x 10⁸ = 21 x 10⁸. Clock period = 6.3 s / (2.1 x 10⁹) = 3 x 10⁻⁹ s. Answer: 3.0.

Concept: CPU time = total cycles x cycle time, with total cycles the CPI-weighted instruction counts. The trap is using an unweighted average CPI.

Q62NAT2 marks · no negative· Easy

Consider the following C program. The output of the above program is ___________. (Answer in integer)

#include <stdio.h>
int main(){
    int a;
    int arr[5] = {30,50,10};
    int *ptr;
    ptr = &arr[0] + 1;
    a = *ptr;
    (*ptr)++;
    ptr++;
    printf("%d", a + (*ptr) + arr[1]);
    return 0;
}
Answer: 111 - show solution

arr = {30, 50, 10, 0, 0}. ptr = &arr[1], so a = 50. (*ptr)++ makes arr[1] = 51. ptr++ points to arr[2] = 10. Output = a + *ptr + arr[1] = 50 + 10 + 51 = 111. Answer: 111.

Concept: Distinguish (*ptr)++ (increments the pointed-to value) from ptr++ (moves the pointer). a was copied before the increment, so it stays 50.

Q63NAT2 marks · no negative· Easy

Consider the following C program. The output of the given C program is ________. (Answer in integer)

#include <stdio.h>

int g(int n) {
    return (n+10);
}

int f(int n) {
    return g(n*2);
}

int main() {
    int sum, n;
    sum=0;
    for (n=1; n<3; n++)
        sum += g(f(n));
    printf ("%d", sum);
    return 0;
}
Answer: 46 - show solution

g(f(n)) = (2n + 10) + 10 = 2n + 20. The loop runs for n = 1 and 2: 22 + 24 = 46. Answer: 46.

Concept: Compose the functions symbolically before tracing. The trap is running the loop three times; n < 3 stops after n = 2.

Q64NAT2 marks · no negative· Hard

A quadratic polynomial (x - α)(x - β) over complex numbers is said to be square invariant if (x - α)(x - β) = (x - α²)(x - β²). Suppose from the set of all square invariant quadratic polynomials we choose one at random. The probability that the roots of the chosen polynomial are equal is __________. (rounded off to one decimal place)

Answer: 0.5 - show solution

The root multisets must agree: {α, β} = {α², β²}. Case 1: α² = α and β² = β, so α, β ∈ {0, 1}: polynomials x², x(x - 1), (x - 1)². Case 2: α² = β and β² = α, so α⁴ = α, giving α = 0 (β = 0), α = 1 (β = 1), or α a primitive cube root of unity ω with β = ω², giving (x - ω)(x - ω²) = x² + x + 1. Distinct polynomials: x², x² - x, x² - 2x + 1, x² + x + 1. Equal roots in x² and (x - 1)²: probability 2/4 = 0.5. Answer: 0.5.

Concept: Count distinct polynomials, not ordered root pairs. The trap is missing the complex cube-root case or double-counting (ω, ω²) and (ω², ω).

Q65NAT2 marks · no negative· Moderate

The unit interval (0,1) is divided at a point chosen uniformly distributed over (0,1) in ℝ into two disjoint subintervals. The expected length of the subinterval that contains 0.4 is ___________. (rounded off to two decimal places)

Answer: 0.7 to 0.8 - show solution

Let the cut be U ~ Uniform(0,1). If U < 0.4, 0.4 lies in (U, 1) of length 1 - U; if U > 0.4, it lies in (0, U) of length U. E = ∫ from 0 to 0.4 of (1 - u) du + ∫ from 0.4 to 1 of u du = (0.4 - 0.08) + (0.5 - 0.08) = 0.32 + 0.42 = 0.74. This lies in the accepted range 0.7 to 0.8. Answer: 0.74.

Concept: Condition on where the cut falls relative to the fixed point. The trap is answering 0.5: the piece containing a given point is size-biased, so it is longer on average.

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