GATE / CS ARCHIVE

PAPER / ORIGINAL ORDER

GATE 2025 · Set 2

65 questions

Paper analysis: marks by subject, top topics and repeated questions →

03:00:00
1 mark · MCQ
Report issue

Vocabulary & Verbal Analogies

Question 1, GATE 2025: Choose the word that best fills this sentence: Although Rehman initially hesitated, his _____ to help the project succeed never weakened.
Options: A. ambivalence; B. satisfaction; C. resolve; D. revolve.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

The phrase “never weakened” describes a continuing strength of purpose. The opening contrast says that hesitation existed initially, but the quality in the blank remained firm. “Resolve” is a noun meaning determination or a firm intention, so “his resolve to help” has both the required meaning and the correct grammatical construction.

A is unsuitable because ambivalence means mixed or conflicting feelings, rather than determination. B means contentment, which does not naturally describe a firm commitment “to contribute.” D, “revolve,” is a verb meaning turn around or move in an orbit; it cannot serve as the required noun here. Thus the sentence contrasts initial uncertainty with lasting determination. Answer: C.

Original paper, page 1 · Answer key

1 mark · MCQ
Report issue

Vocabulary & Verbal Analogies

Question 2, GATE 2025: Complete the analogy using the same relationship: bird : nest :: bee : _____.
Options: A. kennel; B. hammock; C. hive; D. lair.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

First identify the relationship rather than looking for something merely associated with a bee. A nest is the dwelling or nesting structure of a bird. The analogous dwelling for bees is a hive, giving bird → nest and bee → hive.

A kennel is a dog's shelter. A hammock is a suspended bed, not the characteristic home of bees. A lair is a resting place or den, usually of a wild animal. Only “hive” preserves the animal-to-dwelling relationship in this analogy. Answer: C.

Original paper, page 2 · Answer key

1 mark · MCQ
Report issue

Algebra, Equations & Number Patterns

Question 3, GATE 2025: Real constants P and Q satisfy P e^x = Q e^(−x) for every real x. Which assertion must hold?
Options: A. P=Q=0; B. P=Q=1; C. P=1 and Q=−1; D. P/Q=0.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

The important condition is “for every real x,” not just one value of x. Substitute x=0. Since e0=1, the identity becomes P=Q. Next substitute x=1 and use Q=P:
P e = P e−1, so P(e−e−1)=0.
Because e and e−1 are unequal, their difference is nonzero. Hence P=0, and the first equation gives Q=0. Conversely, P=Q=0 makes both sides zero for every x, so it satisfies the original condition.

B works at x=0 but fails at x=1. C already fails at x=0. D is not an alternative way to state the answer: at P=Q=0 the quotient P/Q is undefined. Dividing the original equation by P or Q would therefore wrongly discard the actual solution. Answer: A.

Original paper, page 3 · Answer key

1 mark · MCQ
Report issue

Geometry & Spatial Aptitude

Question 4, GATE 2025: A six-square paper net is folded into a cube. Describe the net on a square grid as follows: a row of four squares, left to right, is [blank, hollow upward triangle, blank, filled upward triangle]. A filled-circle square lies immediately above the hollow-triangle square, and a hollow-circle square immediately below it. Which depicted cube is possible?
Options, listing the front/top/right visible faces: A. hollow triangle / filled circle / blank; B. hollow triangle / blank / filled triangle; C. hollow triangle / blank / blank; D. hollow triangle / filled triangle / filled circle. The triangle in A is upright on the front face, as in the net.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Keep the hollow-triangle square as the front face. Folding the squares immediately left and right of it produces the left and right faces; these are the two blank squares. They are opposite, not adjacent. The filled-circle square folds to the top, and the hollow-circle square to the bottom, making those circles another opposite pair. The fourth square in the horizontal strip folds around behind the front face, so the filled triangle is opposite the hollow triangle.

Now test each candidate. A shows the hollow triangle in front, the filled circle above it, and the adjacent blank square to its right. This is obtained directly by the folding described, including the upright triangle orientation. B and D put both triangle faces next to each other, impossible because they are opposite. C makes both blank faces visible as adjacent top and right faces, also impossible. Opposite faces cannot share an edge or the same visible corner. Answer: A.

Original paper, page 4 · Answer key

1 mark · MCQ
Report issue

Algebra, Equations & Number Patterns

Question 5, GATE 2025: Let p1 and p2 be arbitrary primes, not necessarily distinct. Which assertion holds for every such pair?
Options: A. p1+p2 is not prime; B. p1p2 is not prime; C. p1+p2+1 is prime; D. p1p2+1 is prime.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Every prime is an integer at least 2. The product p1p2 has p1 as a divisor, with 1<p1<p1p2 because p2≥2. It therefore has a nontrivial divisor and is composite. This argument also works when p1=p2; for example, 2·2=4. Thus B is universally true.

The other statements are universal claims, so one counterexample refutes each. A fails for p1=2,p2=3, since the sum is the prime 5. C fails for 3 and 5, since 3+5+1=9. D fails for the same pair, since 3·5+1=16. Checking just pairs of odd primes for A would miss the special even prime 2. Answer: B.

Original paper, page 5 · Answer key

2 marks · MCQ
Report issue

Reading Comprehension & Verbal Reasoning

Question 6, GATE 2025: Ramya says to Josephine: “Even if I had known that you were in the hospital, I would not have gone there to see you.” Based only on this remark, choose the intended inference.
Options: A. Ramya knew about the hospitalization; B. Ramya did not know about it; C. they were formerly close friends but are no longer close; D. Josephine was hospitalized because of a leg injury.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

The published answer uses the usual conversational reading of the past counterfactual “if I had known.” A speaker normally uses this construction to contrast a hypothetical past state with what actually happened: Ramya did not know, and says that even knowledge would not have changed her decision not to visit. On this intended reading, B is the best choice.

The remark provides no history of the friendship, so C adds information that is not given. It gives no medical cause, so D is unsupported. A runs against the intended counterfactual implication.

Logical qualification: the ordinary inference of ignorance is pragmatic, not an unconditional theorem of truth-functional logic. Counterfactual conditionals, particularly “even if” constructions, can be used without asserting the falsity of their antecedents. Therefore a strictly formal reading of “logically correct inference” is under-specified. Retain B as the official scoring answer while preserving discrepancy CS-2025-S2-Q6-COUNTERFACTUAL; do not teach the ignorance inference as a universally valid propositional deduction.

Original paper, page 6 · Answer key

2 marks · MCQ
Report issue

Data Interpretation & Logical Reasoning

Question 7, GATE 2025: A letter code maps IMAGE to FHBNJ and FIELD to EMFJG. Using the simple rule consistent with both examples, choose the code for BEACH.
Options: A. CEADP; B. IDBFC; C. JGIBC; D. IBCEC.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Reverse the order of the input letters, then replace each letter with its next alphabet letter. Verify both parts of the rule on both examples:
IMAGE → EGAMI → FHBNJ, because E→F, G→H, A→B, M→N, I→J.
FIELD → DLEIF → EMFJG, because D→E, L→M, E→F, I→J, F→G.

Apply the same operations to BEACH. Reversal gives HCAEB; incrementing each letter gives I, D, B, F, C. The result is IDBFC, which is option B. Reversing without advancing, or advancing without reversing, would not reproduce the supplied examples. As with most coding puzzles, finitely many examples do not determine a unique arbitrary function; this is the straightforward common rule selected by the offered choices.

Original paper, page 7 · Answer key

2 marks · MCQ
Report issue

Algebra, Equations & Number Patterns

Question 8, GATE 2025: For iterations i=0,1,2,3, the input I is [20,−4,10,15], output X is [20,16,26,41], and output Y is [20,−80,−800,−12000]. Choose recurrences for i>0.
A. X(i)=X(i−1)+I(i); Y(i)=Y(i−1)I(i).
B. X(i)=X(i−1)I(i); Y(i)=Y(i−1)+I(i).
C. X(i)=X(i−1)I(i); Y(i)=Y(i−1)I(i).
D. X(i)=X(i−1)+I(i); Y(i)=Y(i−1)I(i−1).
Tap to enlarge
Your answer
Answer & solution

Official answer: A

For X, take consecutive differences: 16−20=−4, 26−16=10, and 41−26=15. Each difference equals the current input, so X(i)=X(i−1)+I(i). Equivalently, X is the running sum including I(0).

For Y, check the products: 20·(−4)=−80, (−80)·10=−800, and (−800)·15=−12000. Thus Y(i)=Y(i−1)I(i), a running product. These two recurrences together are A.

B and C predict X(1)=20·(−4)=−80 rather than 16, so they fail immediately. D has the correct X recurrence but uses the previous input for Y: it would predict Y(1)=20·20=400. The initialization at i=0 is supplied separately; the recurrences begin at i=1. Answer: A.

Original paper, page 8 · Answer key

2 marks · MCQ
Report issue

Geometry & Spatial Aptitude

Question 9, GATE 2025: PQRS is a square of side 2 cm, with P at upper left, Q lower left, R lower right, and S upper right. PLMN is a rectangle whose vertices are in that order; L lies on QR, and side MN passes through S. Find its area in cm².
Options: A. 2√2; B. 2; C. 8; D. 4. The drawing is illustrative, not to scale.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Use triangle PLS to avoid calculating the rectangle's tilt. Relative to base PS, this triangle has base 2 cm and altitude 2 cm, because L lies on QR, a line parallel to PS and 2 cm away. Consequently area(PLS)=(1/2)·2·2=2 cm² regardless of L's position.

Now regard PL as the triangle's base. Since S is on the rectangle's opposite side MN, its perpendicular distance from PL equals the rectangle's other side length. Hence triangle PLS has exactly half the area of rectangle PLMN. The rectangle therefore has area 2·2=4 cm².

A coordinate check gives the same invariant: set P=(0,2), L=(t,0), S=(2,2). Twice the triangle area is |det((t,−2),(2,0))|=4, which equals the rectangle area. The side lengths can change as L moves, but their product does not. Answer: D. The stated incidence and rectangle relations, rather than measured angles in the figure, determine the result.

Original paper, page 9 · Answer key

2 marks · MCQ
Report issue

Data Interpretation & Logical Reasoning

Question 10, GATE 2025: A river divides land into five zones Z1,…,Z5. A bridge over each labelled segment connects the following pair of zones: P: Z1–Z2; Q: Z1–Z3; R: Z2–Z3; S: Z1–Z5; T: Z3–Z5; U: Z5–Z4; V: Z3–Z4. Choose a listed set of bridges that connects every zone with the fewest bridges.
Options: A. P,Q,T; B. P,Q,S,T; C. Q,R,T,V; D. P,Q,S,U,V.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Replace each land zone by a vertex and each possible bridge by an undirected edge. Connecting all five vertices requires at least 5−1=4 edges: starting from five isolated components, one edge can reduce the component count by at most one. A connected set with exactly four edges is a spanning tree and attains this lower bound.

C uses Q,R,T,V, all incident to Z3. These connect Z3 respectively to Z1,Z2,Z5,Z4, so every zone is reachable and four bridges suffice. A has only three bridges and cannot connect five vertices; in particular, it never reaches Z4. B also omits both U and V, the only links to Z4, so its four bridges do not provide connectivity. D does connect the zones, but uses five bridges and is not minimal. Thus C is the required optimal choice. The full edge-to-zone correspondence above was read from the source river map.

Original paper, page 10 · Answer key

1 mark · MCQ
Report issue

Linear Algebra

Question 11, GATE 2025: For A=[[1,2],[2,−1]], determine A^8.
Options: A. 25I; B. 125I; C. 625I; D. 3125I, where I is the 2×2 identity matrix.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Square the matrix first rather than multiplying eight copies in sequence:

A²=[[1·1+2·2, 1·2+2·(−1)], [2·1+(−1)·2, 2·2+(−1)·(−1)]]
   =[[5,0],[0,5]]=5I.

Powers of the same matrix associate, so A8=(A²)4=(5I)4=54 I=625I. Thus the diagonal entries are both 625 and the off-diagonal entries are zero. Notice that squaring 5I four times is not what is required: (A²)4 means four factors of 5I. The other listed scalar multiples are neighboring powers of 5 but correspond to different even powers of A. Answer: C.

Original paper, page 11 · Answer key

1 mark · MCQ
Report issue

Calculus

Question 12, GATE 2025: Find x>1 satisfying ∫ from 1 to x of t ln(t) dt = 1/4.
Options: A. √e; B. e; C. e²; D. e−1.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Use integration by parts with u=ln t and dv=t dt. Then du=dt/t and v=t²/2, giving
∫t ln t dt=(t²/2)ln t−(1/2)∫t dt=(t²/2)ln t−t²/4.
At t=1, this antiderivative equals −1/4. Therefore the definite integral is (x²/2)ln x−x²/4+1/4.

Set this expression equal to 1/4 and cancel the constants:
x²(2 ln x−1)/4=0.
The requirement x>1 rules out x=0 and gives ln x=1/2, hence x=e1/2=√e. It satisfies x>1. The integrand t ln t is positive for t>1, so the definite integral is strictly increasing on the allowed interval, making this solution unique. D is e−1, which is greater than 1, so it does not violate the domain restriction. However, e−1>√e, so strict increase of the integral shows that D also gives a value larger than 1/4, as do B and C. Answer: A.

Original paper, page 11 · Answer key

1 mark · MCQ
Report issue

Tree Properties & Traversals

Question 13, GATE 2025: A nonempty binary tree has n nodes, and every node has either zero or exactly two children. How many nodes have two children?
Options: A. (n−2)/2; B. (n−1)/2; C. n/2; D. (n+1)/2.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Let i be the number of internal nodes and l the number of leaves, so n=i+l. Count the tree edges in two ways. Every non-root node has exactly one parent, giving n−1 edges in total. On the other hand, each internal node contributes two parent-to-child edges and each leaf contributes none, giving 2i edges. Therefore 2i=n−1 and i=(n−1)/2.

This also implies l=i+1=(n+1)/2, which explains why D is a plausible but incorrect distractor: it counts leaves. Such a tree has odd n, as n=2i+1. At the boundary n=1, the root is a leaf and the formula gives zero two-child nodes, as required. This is a full/proper binary tree property; it does not require the tree to be balanced or all leaves to be at the same depth. Answer: B.

Original paper, page 12 · Answer key

1 mark · MCQ
Report issue

Linear Algebra

Question 14, GATE 2025: Nonsingular 3×3 matrices L,M,N satisfy L²=L^(−1), M=L^8, and N=L². Find det(M−N).
Options: A. 0; B. 1; C. 2; D. 3.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Because L is invertible, multiply L²=L−1 by L to obtain L³=I. Its powers therefore repeat with period dividing three. Reduce the exponent 8 modulo 3:
L8=(L³)² L²=I²L²=L².
Thus M=N, and M−N is the 3×3 zero matrix. Its determinant is zero, giving A.

Do not replace det(M−N) by det M−det N: determinants are not additive in that way. Also, the fact that M and N individually are nonsingular does not make their difference nonsingular. In this problem their difference is the clearest possible singular matrix, even though both original matrices have inverses.

Original paper, page 13 · Answer key

1 mark · MCQ
Report issue

Proof Techniques & Number Theory

Question 15, GATE 2025: P(x) is any predicate on the natural numbers, with 0 included. Which implication is valid for every P?
A. [P(0) and ∀x(P(x)⇒P(x+1))] ⇒ ∀x P(x).
B. [P(0) and ∀x(P(x)⇒P(x−1))] ⇒ ∀x P(x).
C. [P(1000) and ∀x(P(x)⇒P(x−1))] ⇒ ∀x P(x).
D. [P(1000) and ∀x(P(x)⇒P(x+1))] ⇒ ∀x P(x).
For downward steps, interpret the implication only where x−1 is in the domain.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

A is the induction principle. P(0) supplies the first case. The upward step gives P(1) from P(0), then P(2) from P(1), and so on. Every nonnegative integer is reached after finitely many upward steps, proving ∀x P(x).

The direction of the step must match the base and the target domain. B starts at the smallest element and moves downward, so it cannot establish any positive case. For example, P(x) meaning “x=0” satisfies the meaningful downward condition and P(0), but not all natural numbers satisfy P. C can cover 0 through 1000, not larger numbers; P(x) meaning “x≤1000” is a counterexample. D can cover 1000 upward, but not smaller numbers; use P(x) meaning “x≥1000.” Thus A alone is valid. Literally writing P(−1) for a predicate only defined on natural numbers is a domain issue in B/C; it does not supply the missing coverage.

Original paper, page 13 · Answer key

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Other / Mixed Topics

Question 16, GATE 2025: Assess two statements: (i) ARP maps an IP address to the corresponding hardware/link-layer address; (ii) a TCP segment from S to R cannot simultaneously contain S-to-R data and an acknowledgment for R-to-S traffic.
Options: A. both true; B. (i) true and (ii) false; C. (i) false and (ii) true; D. both false.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

For the IPv4 local-link setting, ARP resolves a next-hop IPv4 address to a link-layer address, such as an Ethernet MAC address. A host broadcasts an ARP request for the local next hop, and the reply supplies the hardware address used in the frame. This makes (i) true; ARP is not a mechanism for finding an arbitrary remote host's MAC through multiple routers.

TCP is full duplex. A segment has separate sequence-number and acknowledgment-number fields as well as a payload. The payload can carry bytes from S to R while the acknowledgment field, with ACK set, reports bytes already received by S from R. Combining them is called acknowledgment piggybacking and saves a separate ACK-only packet. Therefore (ii), which says they cannot be combined, is false. Answer: B.

Original paper, page 14 · Answer key

1 mark · MCQ
Report issue

Routing Algorithms

Question 17, GATE 2025: Match routing methods with their usual shortest-path algorithm: (i) distance-vector routing; (ii) link-state routing. Algorithms are (a) Bellman–Ford and (b) Dijkstra.
Options: A. i→a, ii→b; B. i→a, ii→a; C. i→b, ii→a; D. i→b, ii→b.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Distance-vector routing maintains estimates to destinations and exchanges these with neighbors. Router x updates its distance to y using
Dx(y)=min over neighbors v of [cost(x,v)+Dv(y)].
This is the Bellman–Ford recurrence, applied in a distributed fashion. Thus (i) matches (a).

A link-state router learns the network's connectivity and link costs through link-state advertisements. With this graph available locally, it computes a shortest-path tree rooted at itself, conventionally using Dijkstra's algorithm for nonnegative link costs. Thus (ii) matches (b). The important distinction is neighbor distance estimates versus an advertised topology map, not simply that both seek shortest routes. The two correct matches appear together only in A.

Original paper, page 15 · Answer key

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

IP Addressing, Fragmentation & Address Resolution

Question 18, GATE 2025: An IPv4 packet's Protocol field names the protocol carried immediately inside IPv4. Which listed protocol is not normally a possible direct value for this purpose?
Options: A. ICMP; B. IGMP; C. OSPF; D. RIP.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

The IPv4 Protocol field identifies the next encapsulated protocol, not every protocol that may appear farther inside the payload. ICMP, IGMP, and OSPF all run directly over IP and have assigned IPv4 protocol numbers 1, 2, and 89 respectively. Therefore A, B, and C are possible.

RIP messages are carried in UDP datagrams, conventionally using UDP port 520 for RIPv2. In such a packet the IP Protocol field is 17, identifying UDP. RIP is recognized by the transport-layer port and its message format rather than by a direct RIP value in this field. Thus D is the required exclusion. OSPF and RIP are both routing protocols, but they use different encapsulation, so their shared purpose does not imply the same packet layering.

Original paper, page 16 · Answer key

1 mark · MCQ
Report issue

Arrays & Strings

Question 19, GATE 2025: A C program initializes char a[30]="@#Hello World!"; calls stringcopy(a,a+2); and prints a using printf("%s\n",a). The user-defined function is:
void stringcopy(char *s,char *t) { while (*t) *s++ = *t++; }
What is printed before the newline?
Options: A. @#Hello World!; B. Hello World!; C. ello World!; D. Hello World!d!.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Step through it (34 steps)

The source pointer begins at index 2, the H, and the destination begins at index 0. Initially the string occupies indices 0 through 13 and its null terminator is at index 14. The loop copies the 12 non-null characters “Hello World!” from source indices 2…13 into destination indices 0…11.

After the last exclamation mark is copied, t points at index 14. The condition *t is now zero, so the loop stops before copying that null terminator. Destination indices 12 and 13 were never overwritten and still contain the original d and !. The first terminating null remains at index 14. Thus the complete printed sequence is “Hello World!d!”, followed by the newline: D.

The key mistake in the function is failing to copy or append '\0'. This is an explicit forward-copy loop that reads two positions ahead of its writes, so previously overwritten bytes do not corrupt later reads. It should not be confused with calling the standard strcpy on overlapping arrays, which would have undefined behavior.

Original paper, page 17 · Answer key

1 mark · MCQ
Report issue

Searching, Sorting & Selection

Question 20, GATE 2025: An unordered list contains N distinct integers. In the comparison model, what is the minimum number of element comparisons needed to find any element that is not the largest? Assume N≥2.
Options: A. 1; B. N−1; C. N; D. 2N−1.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Compare any two distinct list elements, say a and b. If a<b, return a; otherwise return b. Because the keys are distinct, the returned key is strictly smaller than the other compared key, which also belongs to the list. This is already a certificate that the returned key is not the maximum of the entire list. We do not need to identify the maximum or inspect the other N−2 elements.

One comparison is sufficient and, in the worst-case comparison model, necessary. With zero comparisons there is no ordering evidence about the chosen element; arbitrary distinct input values could make it the largest. N−1 is the familiar bound for finding the actual maximum, which is a stronger problem. The assumption N≥2 is necessary: for N=1 no nonmaximum element exists. Answer: A.

Original paper, page 18 · Answer key

1 mark · MCQ
Report issue

Intermediate Code

Question 21, GATE 2025: For compiler intermediate-code generation, consider: I. backpatching can generate code for Boolean expressions in one pass; II. backpatching can generate code for flow-of-control statements in one pass. Which is correct?
Options: A. I only; B. II only; C. both; D. neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

A branch target may not be known when its branch instruction is first generated. Backpatching emits the instruction with a placeholder target and records its location on a list. Later, when the target's instruction address becomes known, the compiler fills that field without rereading the source.

For a Boolean expression such as a<b && c<d, the compiler can keep true and false lists. A true branch from the first comparison is patched to the start of the second comparison; the final true/false branches are patched to the enclosing statement's destinations. This supports short-circuit Boolean code in one pass, so I is true.

For an if, while, or similar statement, next lists and branch lists are patched when the following block, loop test, or exit becomes known. Thus flow-of-control code can also be generated in one pass, making II true. “One pass” does not prohibit editing previously emitted target fields; that editing is precisely the role of backpatching. Answer: C.

Original paper, page 18 · Answer key

1 mark · MCQ
Report issue

Semantic Analysis & Type Checking

Question 22, GATE 2025: Classify these syntax-directed attribute rules:
1. R→AB with B.i=R.i−1, A.i=B.i, R.i=A.i+1.
2. P→CD with P.i=C.i+D.i, D.i=C.i+2.
3. Q→EF with Q.i=E.i+F.i.
Options list the classification of rules 1,2,3 respectively:
A. [S and L], [S not L], [neither].
B. [neither], [S and L], [S and L].
C. [neither], [L not S], [S and L].
D. [S not L], [L not S], [S and L].
Here S means S-attributed and L means L-attributed.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

An S-attributed definition has only synthesized attributes: the parent obtains its values from children. An L-attributed definition additionally permits a child's inherited attributes to depend on the parent's inherited attributes and on attributes of siblings to that child's left, so a left-to-right evaluation is possible.

Rule 1 assigns attributes on both children, so it is not S-attributed. In particular A.i depends on B.i, an attribute of A's right sibling. That violates the L-attributed direction restriction. The listed dependencies also form the cycle R.i→B.i→A.i→R.i; they do not provide a straightforward acyclic evaluation. Thus rule 1 is neither.

In rule 2, P.i is synthesized, but D.i is inherited from its left sibling C. This is permitted in an L-attributed definition and disallowed in an S-attributed one. Rule 3 only synthesizes the parent's Q.i from E.i and F.i, so it is S-attributed, and every S-attributed definition is also L-attributed. The sequence is [neither], [L not S], [S and L], which is C. The letters used to name an attribute, such as i, do not determine its classification; its dependency does.

Original paper, page 19 · Answer key

1 mark · MCQ
Report issue

IP Addressing, Fragmentation & Address Resolution

Question 23, GATE 2025: Ethernet can carry at most 1500 bytes in its data field. IPv4 uses a 20-byte header with no options. A UDP datagram has 7488 bytes of application data. After IPv4 fragmentation, how many fragments are sent, and what is the total size of the last fragment including its IPv4 header?
Options: A. 5 and 1488 bytes; B. 6 and 88 bytes; C. 6 and 108 bytes; D. 6 and 116 bytes.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Step through it (4 steps)

UDP adds one 8-byte header to its 7488 data bytes. The payload of the original IPv4 datagram is therefore 7496 bytes. Each fragment must fit the 1500-byte Ethernet data field, and each has its own 20-byte IPv4 header. A full fragment can consequently carry 1500−20=1480 payload bytes.

Except for the last fragment, IPv4 fragment payload lengths must be multiples of 8 because fragment offsets are in 8-byte units. Here 1480=185·8, so the full payload size is usable. Divide the original payload: 7496=5·1480+96. There are five full fragments and one final fragment, hence six in total. The last has 96 payload bytes plus a 20-byte IPv4 header, or 116 bytes.

The UDP header is part of the original payload and appears only in the first fragment, not in every fragment. Omitting it would incorrectly give 88 bytes of last payload and 108 bytes including IP; 88 alone would additionally omit the final IP header. Answer: D.

Original paper, page 20 · Answer key

1 mark · MCQ
Report issue

Pushdown Automata

Question 24, GATE 2025: Which family is guaranteed to be accepted by deterministic pushdown automata, meaning that every language in the listed family has some DPDA?
Options: A. every regular language; B. every context-free language; C. every language accepted by an NPDA; D. every decidable language.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

A DPDA can simulate a DFA: copy the DFA's finite control and transitions, and leave the stack unused except for its bottom marker. Therefore every regular language has a deterministic pushdown recognizer, establishing A.

Nondeterministic PDAs recognize exactly the context-free languages, while deterministic PDAs recognize only the deterministic context-free languages, a proper subclass. Thus B and C make the same overly broad guarantee. For example, the unrestricted palindrome language over {a,b} requires guessing the midpoint in the usual PDA construction and is not deterministic context-free; a visible midpoint marker would change the problem.

D is even broader. A decidable language such as {an bn cn:n≥0} can be decided by a Turing machine but is not context-free, so no PDA, deterministic or nondeterministic, accepts it. These statements concern existence of a suitable machine for each language, not one fixed machine that accepts every language at once. Answer: A.

Original paper, page 20 · Answer key

1 mark · MCQ
Report issue

Decidability & Computability

Question 25, GATE 2025: Given arbitrary context-free grammars G1,G2 and a regular expression R, which decision problem has an algorithm that always terminates with the correct yes/no answer?
Options: A. L(G1)=L(G2)? B. L(G1)∩L(G2)=∅? C. L(G1)=L(R)? D. L(G1)=∅?
Tap to enlarge
Your answer
Answer & solution

Official answer: D

CFG emptiness is decidable by identifying productive nonterminals, those that can derive a string containing only terminals. Start by marking a nonterminal with a production containing no nonterminals, including an epsilon production. Repeatedly mark the left side of a production whenever all nonterminals on its right side are already marked. Since there are finitely many nonterminals and marks are only added, this process terminates. The generated language is nonempty exactly when the start symbol is marked. Hence D is decidable.

General equivalence of two CFGs (A) and emptiness of the intersection of two CFLs (B) are undecidable. Do not infer B from single-CFG emptiness: CFLs are not closed under intersection, so there need not be an effectively constructed CFG for the intersection.

C is also undecidable in general despite one language being regular. If it were decidable, choose R to denote Σ*. It would then decide whether an arbitrary CFG generates every string over Σ, the undecidable CFG universality problem. The asymmetry matters: containment of a CFL in a regular language can be decided using intersection with a regular complement, but equality also requires the reverse containment. Answer: D.

Original paper, page 21 · Answer key

1 mark · MCQ
Report issue

CPU Scheduling

Question 26, GATE 2025: Processes P1,P2,P3,P4 arrive at times 0,1,2,8 ms and require 10,13,6,9 ms of CPU time respectively. Scheduling uses preemptive Shortest Remaining Time First with no context-switch cost. Find average turnaround time.
Options: A. 22 ms; B. 15 ms; C. 37 ms; D. 19 ms.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Step through it (7 steps)

Track remaining time at each arrival rather than comparing original burst times throughout. At t=0 only P1 is available. At t=1 P1 has 9 ms left, less than P2's 13, so P1 continues. At t=2 P1 has 8 ms left and P3 arrives needing 6; P3 preempts it and runs from 2 to 8.

At t=8 P3 completes and P4 arrives. Remaining times are P1:8, P2:13, P4:9, so choose P1 for 8…16. Next choose P4 for 16…25, followed by P2 for 25…38. The execution intervals are therefore P1 [0,2), P3 [2,8), P1 [8,16), P4 [16,25), P2 [25,38).

Turnaround equals completion minus arrival: P1=16−0=16, P2=38−1=37, P3=8−2=6, P4=25−8=17 ms. Their sum is 76 ms and the average is 76/4=19 ms. Waiting time would subtract each burst as well; that is not the requested metric. Answer: D.

Original paper, page 21 · Answer key

1 mark · MSQ
Report issue

Transactions & Concurrency Control

Question 27, GATE 2025: Two joint holders simultaneously transfer ₹10000 each from account A to B. Both transactions read A's initial balance as ₹11000 and are allowed to finish. B receives two ₹10000 credits, but A is debited only once and ends at ₹1000. Which ACID properties are certainly violated?
Options: A. atomicity; B. consistency; C. isolation; D. durability.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: B, C

A typical interleaving is: T1 reads A=11000; T2 reads A=11000; each computes 11000−10000=1000; T1 writes A=1000 and T2 overwrites it with the same value. Both credits to B survive. This is a lost update.

Isolation fails because the result is not equivalent to executing the two valid transfers serially. After the first transfer, a serial second transaction would observe A=1000, not the original 11000; it could be rejected for insufficient funds or, if overdraft were permitted, debit to −9000. Neither serial behavior produces the reported one-debit/two-credit result.

Consistency also fails: A decreases by only 10000 while B increases by 20000, so the transfer has created 10000 of aggregate balance rather than conserving it. Atomicity need not fail: both transactions may have executed all their own read/write steps and committed, with the race occurring between otherwise complete transactions. Durability is about retaining committed results despite later failures, and no such loss after a failure is described. Thus only B and C are certain.

Original paper, page 22 · Answer key

1 mark · MSQ
Report issue

Instructions & Addressing Modes

Question 28, GATE 2025: Select the processor properties that belong to its Instruction Set Architecture (ISA).
Options: A. cache capacity; B. processor clock frequency; C. number of cache levels; D. total number of registers.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: D

An ISA is the programmer-visible contract implemented by a processor, including instruction meanings, operand formats, and architectural registers. Therefore the number of registers that machine instructions can name belongs to that contract, making D the intended selection.

Cache capacity and the number of cache levels are generally microarchitectural implementation choices. Two processors may execute the same machine code while using different cache hierarchies. Clock frequency likewise affects execution speed, but is not a definition of the instruction set. Thus A, B, and C are not ISA properties in this question.

There is a necessary terminology qualification: “total number of registers” must mean the architectural register set. Physical registers used for renaming, pipeline latches, and other hidden internal storage need not be specified by the ISA and can vary across implementations. Under the intended architectural interpretation, select D only.

Original paper, page 22 · Answer key

1 mark · MSQ
Report issue

Graph Algorithms

Question 29, GATE 2025: For BFS and DFS on an undirected simple graph G, choose all true statements.
A. A DFS tree is always a shortest-path tree.
B. Every DFS non-tree edge connects a vertex and an ancestor/descendant, described as a forward/back edge.
C. Endpoints of a BFS non-tree edge have source distances differing by at most one.
D. Either repeated BFS or repeated DFS can find all connected components.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: B, C, D

A is false. In a triangle with edges s–u,u–v,s–v, DFS may choose tree edges s–u and u–v. Its tree distance from s to v is then 2 even though the graph contains a length-1 path s–v. DFS prioritizes depth, not distance.

B is true for undirected DFS. If an edge from a currently explored vertex reaches an unvisited vertex, DFS follows it before finishing that subtree. Consequently an undirected non-tree edge cannot join two completely separate DFS subtrees; its endpoints have an ancestor-descendant relationship. It is usually called a back edge when oriented toward the ancestor. The question's “forward/back” wording refers to that relationship, not to a separate undirected cross-edge type.

C follows from shortest-path distances. For any edge u–v, a shortest route to u followed by that edge shows d(s,v)≤d(s,u)+1. Reversing the roles gives d(s,u)≤d(s,v)+1. BFS tree levels equal these distances, so their difference is at most one.

D is true: traverse from an unvisited vertex, mark its entire component, and repeat while any vertex remains unvisited. This works with either BFS or DFS, including isolated vertices. Select B,C,D.

Original paper, page 23 · Answer key

1 mark · MSQ
Report issue

Closure Properties & Language Hierarchy

Question 30, GATE 2025: Match language families (i) context-free, (ii) recursive/decidable, (iii) regular with properties (a) closed under union, (b) not closed under complementation, (c) closed under intersection. Select every option whose three matches are all valid.
A. i→a, ii→b, iii→c.
B. i→b, ii→a, iii→c.
C. i→b, ii→c, iii→a.
D. i→a, ii→c, iii→b.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: B, C

Context-free languages are closed under union: introduce a new start symbol that chooses either grammar. They are not closed under complementation. One way to understand the latter fact is that closure under both union and complement would, by De Morgan's law, imply closure under intersection, which CFLs do not have.

Decidable languages are closed under union and intersection because both deciders halt: run them and combine their Boolean answers with OR or AND. They are closed under complement by swapping acceptance and rejection. Regular languages have all three closures: product automata handle union/intersection, and swapping accepting states in a complete DFA handles complement.

Now inspect each full option. A incorrectly assigns nonclosure under complement to decidable languages. B correctly assigns CFL nonclosure, decidable union closure, and regular intersection closure. C correctly assigns CFL nonclosure, decidable intersection closure, and regular union closure. D incorrectly denies complement closure to regular languages. Therefore B and C are correct. This is not a one-to-one matching puzzle: a family can possess more than one listed closure property.

Original paper, page 24 · Answer key

1 mark · MSQ
Report issue

Boolean Algebra & Logic Gates

Question 31, GATE 2025: A logic circuit has three branches feeding a final OR gate: (1) a NAND of X and Y; (2) an inverter on X; (3) an AND of X and an inverted Y. Select all expressions equal to the output F. Here ¬ means NOT, adjacency means AND, and + means OR.
A. ¬(XY).
B. ¬X+¬Y+X¬Y.
C. ¬(XY)+¬X+X¬Y.
D. X+¬Y.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A, B, C

Read the circuit one gate at a time. The top branch outputs ¬(XY), the middle inverter outputs ¬X, and the bottom AND outputs X¬Y. OR-ing these gives F=¬(XY)+¬X+X¬Y, exactly C.

Apply De Morgan's law: ¬(XY)=¬X+¬Y. Therefore F=¬X+¬Y+¬X+X¬Y. Idempotence removes the duplicate ¬X, leaving ¬X+¬Y+X¬Y, which is B. Absorption gives ¬Y+X¬Y=¬Y, so F=¬X+¬Y=¬(XY), which is A.

For D, use a distinguishing input instead of relying on appearance. When X=Y=1, all three actual circuit branches output zero, so F=0. But X+¬Y=1+0=1. Thus D is not equivalent. A truth-table check gives F=1,1,1,0 for XY=00,01,10,11, the NAND pattern. Select A,B,C.

Original paper, page 25 · Answer key

1 mark · NAT
Report issue

Data Representation & Arithmetic

Question 32, GATE 2025: Ordinary radix-2 Booth multiplication is applied to signed 16-bit two's-complement operands M=1100 1101 1110 1101 and Q=1010 0100 1010 1010. How many additions and subtractions of the multiplicand occur in total? Count arithmetic operations, not shifts.
Tap to enlarge
Answer & solution

Official answer: 13

Step through it (18 steps)

In radix-2 Booth multiplication append q−1=0 to the multiplier and inspect (qi,qi−1) for i=0,…,15. A pair 01 causes addition of M, 10 causes subtraction of M, and 00 or 11 causes neither. Each iteration still performs its arithmetic right shift, but shifts are not included in the question's count. The count depends on the multiplier's bit transitions, not on the value of M.

Read Q from its least significant end. The positions producing subtraction (10) are i=1,3,5,7,10,13,15, seven positions. The positions producing addition (01) are i=2,4,6,8,11,14, six positions. The remaining positions i=0,9,12 have equal adjacent bits and require no arithmetic update.

Thus there are 7+6=13 additions/subtractions during the 16 iterations. Do not append an extra seventeenth correction for the leading one: the fixed-width signed Booth algorithm already handles that sign bit through its arithmetic shifts. Answer: 13.

Original paper, page 25 · Answer key

1 mark · NAT
Report issue

Control Flow & Loop Tracing

Question 33, GATE 2025: Find the integer printed by this C fragment:
int x=126,y=105;
do { if(x>y) x=x-y; else y=y-x; } while(x!=y);
printf("%d",x);
Tap to enlarge
Answer & solution

Official answer: 21

Step through it (21 steps)

Trace the pair (x,y) after each execution of the body:
(126,105) → (21,105) → (21,84) → (21,63) → (21,42) → (21,21).
At the first step x>y, so only x changes. Thereafter y>x until equality is reached, so y is reduced repeatedly by 21. The loop test sees x==y after the fifth iteration and stops. The printed x is 21.

This is the subtraction version of Euclid's algorithm. Replacing a larger positive integer by its difference with the smaller preserves the set of common divisors, and hence the gcd. At termination the two equal positive values must equal gcd(126,105)=21. Remember that a do-while executes the body before testing its condition; here the initial values differ, so that distinction does not alter the trace. Answer: 21.

Original paper, page 26 · Answer key

1 mark · NAT
Report issue

Counters & Timing

Question 34, GATE 2025: A 4-bit ripple counter has a waveform period of 64 microseconds at its last flip-flop. Find the input clock frequency in kHz.
Tap to enlarge
Answer & solution

Official answer: 250

Each flip-flop toggles on every active edge of its input clock. Two toggles complete one output cycle, so each stage divides the frequency by two and doubles the period. With four stages the final output frequency is f_in/24=f_in/16, and its period is 16T_in.

Given T_last=64 μs, the input period is T_in=64/16=4 μs. Therefore f_in=1/(4×10−6 s)=250000 Hz=250 kHz. As a check, the last stage frequency is 1/(64 μs)=15.625 kHz and multiplying it by 16 again gives 250 kHz.

The phrase “frequency of the ripple counter” in the question is interpreted as the input clock frequency, not the final-stage output frequency. Do not divide that final output frequency by 16 a second time. Answer: 250.

Original paper, page 26 · Answer key

1 mark · NAT
Report issue

Binary Search & Balanced Trees

Question 35, GATE 2025: Insert 10,−4,15,30,20,5,60,19 in that order into an initially empty ordinary binary search tree, with no balancing rotations. How many edges are on the path from node 19 to the root?
Tap to enlarge
Answer & solution

Official answer: 4

Step through it (10 steps)

Insert by comparing each new key with the nodes on its search path. The first key 10 becomes the root. −4 is its left child and 15 its right child. Next 30 becomes the right child of 15; 20 becomes the left child of 30. The key 5 goes right of −4, and 60 goes right of 30.

For 19, compare with 10: go right. Compare with 15: go right. Compare with 30: go left. Compare with 20: go left and insert there. Thus its root path is 10→15→30→20→19.

There are five nodes on that path but four edges, so the requested distance is 4. This is its depth when the root has depth zero. The left branch containing −4 and 5, and the right branch containing 60, do not contribute to this path. Answer: 4.

Original paper, page 26 · Answer key

2 marks · MCQ
Report issue

Data Link, Framing, Error Control & ARQ

Question 36, GATE 2025: Stop-and-wait sends 3000-bit frames on a 2000-bit/s channel. One-way propagation delay is 100 ms. Ignore processing time and ACK transmission time. Which offered percentage best approximates channel utilization?
Options: A. 88.23; B. 93.75; C. 85.44; D. 66.67.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Step through it (4 steps)

Frame transmission takes T_tx=3000/2000=1.5 seconds. Once the last data bit leaves the sender it still needs 0.1 seconds to reach the receiver. The negligibly short ACK then needs another 0.1 seconds to propagate back. Therefore the interval from starting one frame until being allowed to start the next is T_cycle=1.5+0.1+0.1=1.7 seconds.

The sender uses the channel to transmit data for 1.5 seconds of each 1.7-second cycle, so utilization is U=1.5/1.7=15/17≈0.88235294, or 88.235294 percent. Equivalently U=1/(1+2a), where a=T_prop/T_tx.

A is the nearest listed choice. The displayed 88.23 is a truncated/approximate option; conventional rounding of the calculated percentage to two decimal places gives 88.24. Ignoring the return propagation would overestimate utilization, while treating the 100 ms as a round trip would change the supplied assumption. Answer: A.

Original paper, page 27 · Answer key

2 marks · MCQ
Report issue

Graph Algorithms

Question 37, GATE 2025: In an undirected graph with positive edge weights, add the same positive constant α to every edge. How are minimum spanning trees (MSTs) and shortest paths (SPs) affected?
A. Every MST and every SP remain optimal.
B. MSTs may change; every SP remains optimal.
C. Every MST remains optimal; SPs may change.
D. Both MSTs and SPs may change.
Consider components where the corresponding spanning tree/path exists.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

For a graph with n vertices, every spanning tree uses exactly n−1 edges. Its new weight is w'(T)=w(T)+(n−1)α. Any two trees receive exactly the same increment, so their weight difference and ordering are unchanged. In particular, every old MST is still an MST, and ties between MSTs are preserved.

Paths do not all contain the same number of edges. Consider a triangle with u–w of weight 1, w–v of weight 1, and u–v of weight 3. Initially the two-edge route from u to v costs 2, beating the direct edge's 3. Add α=2 to every edge. The two-edge route now costs 3+3=6, whereas the direct edge costs 5, so the old shortest path is no longer shortest.

Thus constant addition preserves MSTs but need not preserve shortest paths: C. The distinction is a fixed edge count across all spanning trees versus a potentially variable edge count across paths. Multiplying every edge by a positive constant would preserve both, but that is a different operation.

Original paper, page 28 · Answer key

2 marks · MCQ
Report issue

Other / Mixed Topics

Question 38, GATE 2025: Meld combines two size-n instances into one of the same data structure. Let P be an unsorted doubly linked list with head and tail pointers, Q an array-based min-heap, and R a binary search tree. Choose the best worst-case time complexities.
A. P Θ(1), Q Θ(n), R Θ(n).
B. P Θ(1), Q Θ(n log n), R Θ(n).
C. P Θ(n), Q Θ(n log n), R Θ(n²).
D. P Θ(1), Q Θ(n), R Θ(n log n).
Tap to enlarge
Your answer
Answer & solution

Official answer: A

P: join the first list's tail to the second list's head, set the corresponding previous pointer, and choose the resulting head and tail. Only a constant number of pointer changes are needed, with separate constant-time handling of empty lists. The list is unsorted, so no ordering merge is required: Θ(1).

Q: place both arrays into one 2n-element array and apply bottom-up build-heap. Build-heap is linear, not Θ(n log n): there are many nodes near leaves that require only short sift-down operations, and summing their heights gives O(n). The concatenation/output work is also linear, so Θ(n) suffices. Inserting each item separately is valid but needlessly slower in the worst case.

R: perform inorder traversals to get two sorted sequences in Θ(n), merge them in Θ(n), and build a balanced BST from the merged sequence by choosing midpoints recursively in Θ(n). Arbitrarily interleaved key sets require linear worst-case work/comparisons to establish their joint ordering, so the meld bound is Θ(n), rather than the cost of repeated naive insertions into a possibly skewed tree.

The three bounds are Θ(1),Θ(n),Θ(n): A.

Original paper, page 29 · Answer key

2 marks · MCQ
Report issue

Cache Memory

Question 39, GATE 2025: A byte-addressable system has a direct-mapped cache. Addresses contain 4 tag bits and 12 cache-index bits; each cache block holds one byte. Choose main-memory address capacity and cache data capacity, respectively.
Options: A. 64 KB,4 KB; B. 128 KB,16 KB; C. 64 KB,8 KB; D. 128 KB,6 KB. Use KB=1024 bytes. The original wording says no other information is stored per block.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

A one-byte block needs log2(1)=0 block-offset bits. Therefore each address has tag+index+offset=4+12+0=16 bits. With byte addressing it identifies 216 bytes, or 65536 bytes=64 KB of main memory.

The 12 index bits select one of 212=4096 cache lines. Each line holds one byte of data, so the cache data capacity is 4096 bytes=4 KB. This gives A.

Distinguish data capacity from total physical storage. The tag itself occupies 4 bits per line, so explicitly counting stored tags would add 4096·4 bits=2048 bytes=2 KB, making 6 KB before any other metadata. The offered correct option and standard cache-capacity convention use data bytes only. The original “no other information” wording does not turn the 4 tag bits into addressable data, and no option pairs the 64-KB address space with 6-KB physical storage. Answer: A under the stated data-capacity interpretation.

Original paper, page 30 · Answer key

2 marks · MCQ
Report issue

Parsing & Syntax Analysis

Question 40, GATE 2025: For grammar S→Aa | bAc | dc | bda and A→d, choose the parsing classification.
Options: A. neither LALR(1) nor SLR(1); B. CLR(1) but not LALR(1); C. LALR(1) but not SLR(1); D. both LALR(1) and SLR(1).
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Step through it (3 parts)

First compute FOLLOW(A). In S→Aa, a follows A; in S→bAc, c follows A. Thus FOLLOW(A)={a,c}.

The LR(0) state reached by reading d directly from the start contains A→d· and S→d·c. SLR puts the reduction A→d on every symbol in FOLLOW(A), including c, but S→d·c requires shifting c. This is a shift/reduce conflict. Likewise, after reading bd the state contains A→d· and S→bd·a, producing a conflict on a. So the grammar is not SLR(1).

Canonical LR(1) retains the particular context. After the initial d, the completed item is [A→d·,a]; it reduces only on a, while S→d·c shifts c. After bd, the completed item is [A→d·,c]; it reduces only on c, while S→bd·a shifts a. These actions do not conflict.

LALR merges states only when their complete LR(0) cores are identical. The two potentially troublesome states have different S items, S→d·c versus S→bd·a, so they are not merged merely because both contain A→d·. All other reductions arise in completed S productions or similarly nonconflicting states. Hence the precise lookahead separation survives LALR construction. Answer: C.

Original paper, page 30 · Answer key

2 marks · MCQ
Report issue

Searching, Sorting & Selection

Question 41, GATE 2025: An array A[1…n] has distinct elements and is bitonic: for some 1≤i≤n, A[1…i] is increasing and A[i+1…n] is decreasing. The boundary comparison is not specified. Find the best possible worst-case comparison bound for searching for a supplied key.
Options: A. Θ(n); B. Θ(1); C. Θ((log n)²); D. Θ(log n).
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Distinctness makes the two monotone parts strict. At the partition boundary, if A[i]<A[i+1], the peak is i+1; otherwise it is i. Thus the array has a single peak, including the possible endpoint peaks of a purely increasing or decreasing array.

Find that peak with binary search on adjacent values. Maintain a candidate interval [lo,hi]. For mid<hi, if A[mid]<A[mid+1], the peak lies strictly to the right of mid; otherwise it lies at mid or to its left. Each comparison discards roughly half the interval, taking O(log n) comparisons. Then binary-search the increasing part in its normal order and the decreasing part with reversed comparison direction. Each search costs O(log n), so their sum, plus peak finding, remains O(log n), not O((log n)²).

For a lower bound, sorted arrays are included among bitonic arrays. In the comparison model, exact membership among n distinct ordered keys has n possible successful positions and requires Ω(log n) comparisons in the worst case. Therefore the attainable bound is Θ(log n): D.

Original paper, page 31 · Answer key

2 marks · MSQ
Report issue

Partial Orders & Lattices

Question 42, GATE 2025: Let F be all functions {1,…,n}→{0,1}, for positive n. Define f≼g exactly when f(x)≤g(x) for every x, using 0≤1. Select true statements.
Options: A. ≼ is symmetric; B. (F,≼) is a partial order; C. (F,≼) is a lattice; D. ≼ is an equivalence relation.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: B, C

Verify the partial-order axioms coordinate by coordinate. Reflexivity holds because f(x)≤f(x). If f≼g and g≼f, then both inequalities force f(x)=g(x) at each x, so f=g; this is antisymmetry. If f≼g and g≼h, transitivity of ≤ gives f≼h. Thus B is true.

For any two functions define m(x)=min(f(x),g(x)) and j(x)=max(f(x),g(x)). Both are still {0,1}-valued functions. The function m is below both f and g; any other common lower bound is below m at every coordinate. Hence m is their greatest lower bound. Similarly, j is their least upper bound. Every pair therefore has a meet and join, establishing the lattice claim C. This is the same ordering as subset inclusion under the identification f↔{x:f(x)=1}.

A is false: the all-zero function is below the all-one function, but the reverse comparison fails for positive n. An equivalence relation must be symmetric, so D is false too. Select B,C. The positive-domain convention matters: if n=0, only the empty function exists and the relation also becomes symmetric.

Original paper, page 31 · Answer key

2 marks · MSQ
Report issue

Logic Minimization & Karnaugh Maps

Question 43, GATE 2025: A 4-variable Karnaugh map for F(w,x,y,z) uses rows wx and columns yz, each in standard Gray order 00,01,11,10. Its rows, from top to bottom, are [1,0,0,1], [0,1,1,0], [0,1,1,0], [1,0,0,1]. Select all equivalent expressions. Use ¬ for complement, adjacency for AND, + for OR.
A. ¬w¬x¬y¬z + w¬x¬y¬z + ¬w¬xy¬z + w¬xy¬z + xz.
B. ¬w¬x¬y¬z + ¬w¬xy¬z + w¬xyz + xz.
C. ¬w¬x¬y¬z + w¬x¬y¬z + w¬x¬yz + xz.
D. ¬x¬z + xz.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A, D

Step through it (14 steps)

The four corner cells are adjacent through the K-map's wraparound boundaries. Across these corners w and y each vary, while x=0 and z=0 remain fixed. Their size-four group therefore contributes ¬x¬z. The central 2×2 group also lets w and y vary, but fixes x=1 and z=1, contributing xz. All eight ones are covered, giving F=¬x¬z+xz, independent of w and y. This is XNOR of x and z, so D is correct.

Expand the first term by inserting (w+¬w)(y+¬y)=1:
¬x¬z = ¬w¬x¬y¬z + w¬x¬y¬z + ¬w¬xy¬z + w¬xy¬z.
Adding xz reproduces A, so A is also correct.

B omits the required one at wxyz=1000: each of its terms is zero there, while the map gives one. C omits the required one at 0010. Either counterexample suffices to reject the corresponding expression. Select A,D.

Original paper, page 32 · Answer key

2 marks · MSQ
Report issue

Linear Algebra

Question 44, GATE 2025: A real 3×3 system PX=Q has an LU factorization P=LU. L is unit lower triangular, L=[[1,0,0],[l21,1,0],[l31,l32,1]], and U is upper triangular with diagonal u11,u22,u33. Select true statements.
A. Solve LY=Q first, then UX=Y, to solve PX=Q.
B. If P is invertible, both L and U are invertible.
C. If P is singular, some diagonal entry of U is zero.
D. If P is symmetric, both L and U are symmetric.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A, B, C

Since PX=LU X, introduce Y=UX. The system becomes LY=Q followed by UX=Y, so A is valid. L has diagonal ones and is always invertible, making the first system solvable by forward substitution. The second is solved by backward substitution when U is nonsingular; if U is singular, its equations instead determine consistency and any free variables. A does not imply every original system has a unique solution.

The determinant of a triangular matrix is the product of its diagonal entries. Thus det L=1 and det P=det L·det U=u11u22u33. If P is invertible, this product is nonzero and both factors are invertible, proving B. If P is singular, the product is zero, so at least one diagonal entry of U is zero, proving C.

For D, take L=[[1,0,0],[1,1,0],[0,0,1]] and U=[[1,1,0],[0,1,0],[0,0,1]]. Their product P=[[1,1,0],[1,2,0],[0,0,1]] is symmetric, but L and U are not symmetric. Symmetry may relate suitable factors to each other's transposes; it does not make each triangular factor symmetric. Select A,B,C.

Original paper, page 33 · Answer key

2 marks · MSQ
Report issue

Stacks & Queues

Question 45, GATE 2025: A stack stores records with distinct positive integer keys. Add MIN, which returns a pointer to the minimum-key record without removing it, in O(1) time while keeping PUSH and POP O(1). Which proposed augmentations suffice?
A. Every record stores a pointer to the smallest-key record below it.
B. Store only one pointer to the current minimum record.
C. Maintain an auxiliary sorted array of all present keys.
D. Maintain a min-heap of all present keys.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A

A preserves the minimum of every stack prefix, which is the information needed after future pops. For an empty stack use a null pointer. When pushing a new record r onto old top t, compare t.key with the key at t's saved below-minimum pointer, if present. The smaller of those records is the minimum of the entire old stack, so store its pointer in r. This takes O(1). MIN compares the current top with its saved below-minimum and returns the smaller. POP simply exposes the previous top, whose saved pointer is still valid because stack deletion has removed nothing below it. Thus all three operations remain O(1).

B alone supports a new minimum on PUSH but loses the information needed when POP removes the current minimum. Finding the next minimum can require scanning the remaining stack. C permits constant-time access to the smallest sorted entry, but inserting an arbitrary new key can require Θ(n) shifts. D exposes its minimum in O(1), but maintaining the heap on insertions and deletions costs O(log n), not O(1) worst case. Those structures do not meet all requirements merely because their MIN operation is fast. Select A only.

Original paper, page 34 · Answer key

2 marks · MSQ
Report issue

Normalization & Decomposition

Question 46, GATE 2025: Relations have the following complete sets of functional dependencies:
R1(A,B,C,D,E): D→E, EA→B, EB→C.
R2(A,B,C,D): A→D, A→B, C→A.
Select true assertions: A. R1 is in 3NF; B. R2 is in 3NF; C. R1 is not in 3NF; D. R2 is not in 3NF.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: C, D

Step through it (2 parts)

For 3NF, every nontrivial dependency X→Y must have X a superkey or each right-hand attribute prime, meaning it belongs to some candidate key. Identify the keys before applying this test.

In R1, A and D never appear on any right-hand side, so neither can be obtained from other attributes and every key must contain both. Compute (AD)+: start with A,D; D→E adds E; EA→B adds B; EB→C adds C. Thus AD determines all five attributes and is the unique candidate key. Only A,D are prime. The dependency D→E violates 3NF: D+=DE is not a superkey and E is nonprime. Hence R1 is not in 3NF.

In R2, C never appears on a right-hand side and must belong to every key. C→A, followed by A→D and A→B, gives C+=ABCD, so C alone is the unique candidate key. A is not a superkey, since A+=ABD lacks C, and D,B are nonprime. Either A→D or A→B therefore violates 3NF. R2 is not in 3NF either. Select C,D.

Original paper, page 35 · Answer key

2 marks · MSQ
Report issue

Virtual Memory & Paging

Question 47, GATE 2025: A demand-paging system has three initially empty frames and reference string [1,2,3,4,5,4,1,6,4,5,1,3,2]. In frame order, the resident triples after each reference are:
1:(1,−,−); 2:(1,2,−); 3:(1,2,3); 4:(1,4,3); 5:(1,4,5); 6:(1,4,5); 7:(1,4,5); 8:(6,4,5); 9:(6,4,5); 10:(6,4,5); 11:(6,1,5); 12:(6,1,3); 13:(2,1,3).
Which policies could produce this trace? A. LRU; B. LFU; C. MFU; D. optimal/farthest-next-use. Frequency-counter lifetime and tie-breaking are not stated.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: D

Our answer: D with lifetime counters; C;D with reset-on-load counters

Test policies at the first point where their required choice disagrees with the trace. LRU fails at reference 4: among pages 1,2,3, page 1 was used least recently, but the trace evicts page 2. LFU fails at reference 8: before loading page 6, resident reference counts are page 1:2, page 4:2, page 5:1. The trace evicts page 1 rather than the least frequent page 5. These counts agree under both lifetime and reset-on-load conventions at that point.

Optimal replacement is possible. At reference 4, pages 1,2,3 are next used at positions 7,13,12, so evict 2. At reference 5, residents 1,4,3 are next used at 7,6,12, so evict 3. At reference 8, residents 1,4,5 are next used at 11,9,10, so evict 1. At references 11,12,13, the displayed victim is never used again, so the trace can choose it among tied infinite-next-use victims. Thus D is valid.

MFU requires a convention. With lifetime counts, reference 11 loads page 1 with its cumulative count now 3. At reference 12, residents have counts 6:1,1:3,5:2, but the trace evicts 5, not 1. So lifetime MFU fails already there; the final eviction also contradicts it.

With counts reset on each page load, however, MFU can reproduce the whole trace: early victims 2 and 3 are tied at 1; at reference 8 choose page 1 tied with 4 at 2; at reference 11 evict 4 at 3; at reference 12 evict 5 at 2; at reference 13 all residents have count 1 and 6 may be evicted. Therefore C,D are possible under this interpretation. Preserve official answer D and discrepancy CS-2025-S2-Q47-MFU-COUNTERS. The ambiguity is about unspecified counters, not an error in the displayed trace.

Original paper, page 36 · Answer key

2 marks · MSQ
Report issue

Deadlocks

Question 48, GATE 2025: There are processes P1,…,P4 and one instance each of resources R1,…,R4. Ri is assigned to Pi. Current waits are P1→R2, P2→R3, P3→R1, P2→R4, P4→R2. The question calls these wait edges “claim edges.” Which actions make the system deadlock-free?
A. Abort P1 alone. B. Abort P3 alone. C. Abort P2 alone. D. Abort P1 and P4.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: C, D

Step through it (5 checks)

Convert each wait on a resource into a wait on its current owner. The wait-for graph has edges P1→P2, P2→P3, P3→P1, P2→P4, P4→P2. It contains the cycles P1→P2→P3→P1 and P2→P4→P2. With one instance of each resource and actual blocking waits, such cycles characterize deadlock.

Aborting P1 removes the first cycle but leaves P2↔P4, so A fails. Aborting P3 has the same problem, so B fails. Aborting P2 removes a vertex common to both cycles. Remaining waits can be satisfied as resources are released, with no cycle left; C works. Aborting P1 and P4 removes one vertex from each cycle, leaving only P2→P3 among the surviving wait edges, so D also works.

The question asks which listed sets suffice, not which set uses the minimum number of abortions. Hence D remains correct even though C resolves the problem with fewer abortions. Use the question's explicit interpretation of “claim” as a current wait; a future potential-claim edge in deadlock-avoidance terminology would not imply the same present deadlock. Select C,D.

Original paper, page 37 · Answer key

2 marks · MSQ
Report issue

Data Representation & Arithmetic

Question 49, GATE 2025: IEEE 754 binary32 registers hold RX=0xC1100000, RY=0x40C00000, RZ=0x41400000, representing numbers X,Y,Z. Select true equations.
A. 4(X+Y)+Z=0. B. 2Y−Z=0. C. 4X+3Z=0. D. X+Y+Z=0.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A, B, C

Step through it (9 steps)

For a normal binary32 number, value=(−1)s·(1+f/223)·2e−127, where s is the sign bit, e the 8-bit biased exponent, and f the 23-bit fraction integer.

RX has s=1, e=130, and f=0x100000=220. Its fractional contribution is 220/223=1/8, so X=−(1+1/8)·23=−9. RY has s=0,e=129,f=0x400000=222, giving Y=(1+1/2)·22=6. RZ has s=0,e=130 and the same fraction, giving Z=(1+1/2)·23=12.

Now evaluate the choices directly: A gives 4(−9+6)+12=−12+12=0; B gives 2·6−12=0; C gives 4·(−9)+3·12=−36+36=0. D gives −9+6+12=9, not zero. These small integer values and intermediate results are exactly representable, so floating-point rounding does not change the conclusions. Select A,B,C.

Original paper, page 38 · Answer key

2 marks · MSQ
Report issue

Boolean Algebra & Logic Gates

Question 50, GATE 2025: Select every Boolean identity valid for all inputs. Use ¬ for NOT, juxtaposition for AND, and + for OR.
A. ¬ABC + A¬B¬C + ¬A¬B¬C + A¬BC + ABC = BC + ¬B¬C + ¬A¬B.
B. AB + ¬AC + BC = AB + ¬AC.
C. (A+C)(¬A+B) = AB + ¬AC.
D. ¬[(A+¬B+¬D)(C+D)(¬A+C+D)(A+B+¬D)] = ¬AD + ¬C¬D.
In expressions such as ¬ABC, the negation applies only to the immediately following variable A; the bracketed negation in D applies to the entire product.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: B, C, D

B is the consensus identity. Split its extra term BC using A+¬A=1:
BC=ABC+¬ABC.
The term ABC is absorbed by AB, and ¬ABC is absorbed by ¬AC. Hence AB+¬AC+BC=AB+¬AC, proving B.

Expand C's left side: (A+C)(¬A+B)=A¬A+AB+¬AC+BC=AB+¬AC+BC. The first product vanishes, and B's consensus simplification yields the stated right side. Thus C holds.

For D, apply De Morgan to the outer complement and then to each sum:
¬[(A+¬B+¬D)(C+D)(¬A+C+D)(A+B+¬D)]
=¬ABD + ¬C¬D + A¬C¬D + ¬A¬BD.
Combine the first and fourth terms: ¬ABD+¬A¬BD=¬AD(B+¬B)=¬AD. Absorb A¬C¬D into ¬C¬D. The result is ¬AD+¬C¬D, so D holds.

A fails at A=0,B=0,C=1. Every term on its left is zero, but the right includes ¬A¬B=1. A single counterexample rejects a claimed identity. Select B,C,D. The scope of all complement bars, especially D's outer complement and its third factor, was checked on the source image.

Original paper, page 38 · Answer key

2 marks · MSQ
Report issue

Parsing & Syntax Analysis

Question 51, GATE 2025: The terminals are if,then,else,a,b,c. Two grammars are:
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.
Select true statements: A. G1 not LL(1), G2 LL(1); B. G1 LL(1), G2 not LL(1); C. neither LL(1); D. both ambiguous.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: C, D

Write i for the complete terminal phrase “if b then” and e for “else.” In G1, the string i i a e a has two parses: i [i a e a] attaches the else to the inner if, while [i [i a] e a] attaches it to the outer if. This is the dangling-else ambiguity.

G2 may resemble a matched/unmatched-if grammar, but its M production ends in S, not in an entirely matched nonterminal. Consequently an unmatched if can occur in that else branch. A concrete ambiguous string is i i c e i c e c. Its first parse is i [i c e (i c e c)]: the initial S uses S→iS, and its inner S→M derives i c e (i c e c). Its second parse is i [i c e (i c)] e c: the outer S→M uses M→i M e S, with its then-branch M deriving i c e (i c) and its final S deriving c. The else tokens attach to different if occurrences, yet the terminal string is identical. Thus G2 is ambiguous too.

An LL(1) grammar is unambiguous, so neither grammar can be LL(1). Directly, G1's two if-alternatives have the same FIRST token, and G2's S alternatives both admit strings beginning with if. These create predictive parsing conflicts. Select C,D.

Original paper, page 39 · Answer key

2 marks · MSQ
Report issue

Regular Expressions & Languages

Question 52, GATE 2025: Let #a(w),#b(w) count symbol occurrences. Which languages are regular?
A. {a^m b^n:m,n≥0}.
B. {a,b}* ∩ {a^m b^n c^(m−n):m≥n≥0}.
C. {w∈{a,b}*: #a(w)≡2 (mod 7), #b(w)≡3 (mod 9)}.
D. {w∈{a,b}*: #a(w)≡2 (mod 7), #a(w)=#b(w)}.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A, C

A is described by the regular expression a*b*, so it is regular. The two block lengths are independent; there is no equality constraint to remember.

For B, membership in {a,b}* excludes every c. Hence m−n=0 and the intersection is exactly {an bn:n≥0}. This is nonregular: for a pumping length p, any allowed pumping segment in the initial a-block of ap bp changes the a-count without changing the b-count.

C needs only finite modular information. A DFA state (r,s) stores #a modulo 7 and #b modulo 9. On a update r to r+1 modulo 7; on b update s to s+1 modulo 9. Start at (0,0), accept (2,3). The 7·9=63-state construction proves regularity, without claiming a state-minimality result.

For D, intersect with the regular language a*b*. If D were regular, this intersection K={ak bk:k≡2 mod 7} would also be regular. Choose an allowed k greater than a proposed pumping length. Any pumping segment within the first p positions consists only of a's; pumping it changes one count and breaks equality. Thus K, and therefore D, is nonregular. A modular restriction alone is finite-state, but it does not eliminate an unbounded equality requirement. Select A,C.

Original paper, page 40 · Answer key

2 marks · MSQ
Report issue

Transactions & Concurrency Control

Question 53, GATE 2025: R_i(V) and W_i(V) denote transaction i reading/writing item V; C_i is its commit. Select all conflict-serializable schedules.
A. R1(X),W2(X),W1(Y),W2(Y),R1(X),W1(X),C2,C1.
B. W2(X),R1(X),W2(Y),W1(Y),R1(X),C2,W1(X),C1.
C. R1(X),W1(Y),W2(X),W2(Y),R1(X),W1(X),C1,C2.
D. W2(X),R1(X),W1(Y),W2(Y),R1(X),C2,W1(X),C1.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: B

Step through it (4 schedules)

Construct a precedence graph with vertices T1,T2. Two operations conflict when they are in different transactions, access the same item, and at least one is a write. An earlier conflicting operation from Ti followed by one from Tj creates edge Ti→Tj. The schedule is conflict-serializable exactly when this graph is acyclic.

In A, the first R1(X) precedes W2(X), giving T1→T2. The later R1(X), and also W1(X), follow W2(X), giving T2→T1. There is a cycle. C has the same two conflicting directions on X, so it also fails.

In B, W2(X) precedes both reads and the write of X by T1. On Y, W2(Y) precedes W1(Y). Thus all intertransaction conflicts point T2→T1; there is no reverse edge. This is conflict-equivalent to serial order T2 followed by T1.

In D, the X conflicts point T2→T1, but W1(Y) precedes W2(Y), adding T1→T2 and creating a cycle. Commit positions do not remove conflicts or make a cyclic precedence graph acyclic. Select B only. Conflict serializability is a property distinct from whether an interleaving satisfies a particular recovery or locking protocol.

Original paper, page 41 · Answer key

2 marks · MSQ
Report issue

SQL & Queries

Question 54, GATE 2025: Schema: Students(rollno,name,age,cgpa), Courses(courseno,cname,credits), Enrolled(rollno,courseno,grade). Primary keys are Students.rollno, Courses.courseno, and the composite Enrolled(rollno,courseno). Which SQL queries retrieve names of students enrolled in course 1470?
A. SELECT S.name FROM Students S WHERE EXISTS (SELECT * FROM Enrolled E WHERE E.courseno=1470 AND E.rollno=S.rollno);
B. SELECT S.name FROM Students S WHERE SIZEOF (SELECT * FROM Enrolled E WHERE E.courseno=1470 AND E.rollno=S.rollno)>0;
C. SELECT S.name FROM Students S WHERE 0 < (SELECT COUNT(*) FROM Enrolled E WHERE E.courseno=1470 AND E.rollno=S.rollno);
D. SELECT S.name FROM Students S NATURAL JOIN Enrolled E WHERE E.courseno=1470;
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A, C, D

A's correlated subquery considers enrollment rows for the current student's rollno and the requested course. EXISTS is true exactly when at least one such row exists, so A returns the desired name.

C tests the same correlated set. COUNT(*) returns a scalar count, including zero when no enrollment matches. The condition 0<count is therefore equivalent to existence, so C is also valid. B tries to use SIZEOF(subquery), which is not the standard SQL operator for counting a query result; COUNT(*) is the relevant aggregate.

For D, the only shared attribute name between Students and Enrolled is rollno, so NATURAL JOIN equates those roll numbers. Filtering the joined row by courseno=1470 selects enrolled students and projecting S.name gives their names. Thus D is the intended third valid query; Courses is unnecessary because the required course number is already stored in Enrolled.

The source marks (rollno,courseno) as Enrolled's composite primary key, so at most one enrollment can match a given student and course. D therefore has the same per-student-row multiplicity as A/C. Different students may share a name, and none of these queries removes such duplicate names. Without the composite-key constraint, a join could repeat a name per matching enrollment, but that is not the stated schema. The correct selection is A,C,D.

Original paper, page 42 · Answer key

2 marks · NAT
Report issue

Cache Memory

Question 55, GATE 2025: A two-level cache has L1 access time 1 ns and hit rate 90%. Conditional on reaching L2, its hit rate is 80%; the L1-miss transfer/access penalty through L2 is 10 ns. An L2 miss adds 100 ns to transfer from main memory. Find average memory access time in ns, to one decimal place, using additive miss penalties.
Tap to enlarge
Answer & solution

Official answer: 4.0

Always pay the 1-ns L1 lookup. With probability 1−0.9=0.1, an L1 miss adds 10 ns for the next level. Of those L1 misses, a fraction 1−0.8=0.2 also miss L2 and incur the additional 100 ns. Therefore
AMAT=1+0.1[10+0.2·100]=1+0.1·30=4.0 ns.

An equivalent path-probability calculation makes the nesting clear. L1 hits occur with probability 0.9 and cost 1 ns. L1 miss/L2 hit occurs with probability 0.1·0.8=0.08 and costs 1+10=11 ns. Misses in both levels occur with probability 0.1·0.2=0.02 and cost 1+10+100=111 ns. Their weighted sum is 0.9·1+0.08·11+0.02·111=4.0 ns.

The L2 hit rate is conditional on an L1 miss, not a separate 80% of all requests. Also, the stated miss penalties are additional times; treating them as inclusive complete-path times would describe a different model. Answer: 4.0.

Original paper, page 43 · Answer key

2 marks · NAT
Report issue

Pipelining & Hazards

Question 56, GATE 2025: A five-stage pipeline has stage delays 180,250,150,170,250 ns. Each inter-stage latch adds 10 ns. With no stalls, how long does execution of 1000 instructions take, in microseconds to two decimal places?
Tap to enlarge
Answer & solution

Official answer: 260.20 to 261.20

Our answer: 261.04

A synchronous pipeline clock must allow its slowest stage plus the latch overhead to complete. Thus T_clock=max(180,250,150,170,250)+10=260 ns. Adding all five stage delays would instead describe an unpipelined or differently timed design; faster stages must still wait for this common clock.

The first instruction completes after five cycles. Once the pipeline is full, one further instruction completes per cycle, so 999 additional instructions take 999 more cycles. Total cycles=k+n−1=5+1000−1=1004.

Execution time is 1004·260=261040 ns. Dividing by 1000 ns per microsecond gives 261.04 μs. The fill/drain accounting is already included in k+n−1; adding separate extra fill and drain terms would double-count. The value lies within the published acceptable range 260.20 to 261.20 μs. Answer: 261.04.

Original paper, page 43 · Answer key

2 marks · NAT
Report issue

Indexing, Storage & Query Processing

Question 57, GATE 2025: A B+ tree node holds at most four keys. One root-to-leaf path is A=(49,77,83,−), B=(7,19,33,44), C=(20*,22*,25*,26*), where stars mark leaf data entries. A pointer between separators k1,k2 covers [k1,k2), and a newly created leaf copies its smallest key into its parent. Insert key 23. What is the smallest separator key in the parent of the resulting leaf that contains 25*?
Tap to enlarge
Answer & solution

Official answer: 33

The insertion belongs in C because 19≤23<33. Its sorted data entries become [20*,22*,23*,25*,26*], exceeding the four-key limit, so C splits. With a 2/3 split, the leaves are [20*,22*] and [23*,25*,26*], and separator 23 is copied up. With a 3/2 split, they are [20*,22*,23*] and [25*,26*], and separator 25 is copied up. Let k be that copied separator, either 23 or 25.

B was already full. After receiving k, its ordered separators are [7,19,k,33,44], so B must split as well. For an internal-node split, the middle separator k is promoted to A rather than kept as a key in either split internal node. The left internal node retains [7,19], and the right retains [33,44]. The leaf holding 25* is on the right side of k and is a child of this right internal node.

Consequently its parent's smallest stored key is 33, even though that parent has a leftmost child whose values can be smaller than 33. A had spare capacity, so receiving k causes no further split. The unspecified 2/3 versus 3/2 leaf convention does not change the requested answer: 33.

Original paper, page 43 · Answer key

2 marks · NAT
Report issue

Virtual Memory & Paging

Question 58, GATE 2025: A byte-addressable logical space has 2^32 bytes and uses two-level paging with 4096-byte pages. Each inner-page-table entry takes 8 bytes, and an inner table occupies one page. An address contains b outer-index bits, an inner-table entry index, and a data-page offset. Find b.
Tap to enlarge
Answer & solution

Official answer: 11

A 4096-byte data page needs log2(4096)=12 offset bits. An inner page table stored in one 4096-byte page holds 4096/8=512=29 entries. Selecting one of those entries therefore needs 9 bits.

The complete logical address has 32 bits, so the remaining outer index has b=32−12−9=11 bits. As a coverage check, each inner table maps 512 data pages, or 512·4096=221 bytes. A 232-byte space therefore needs 232−21=211 such inner-table slots in its outer table.

Do not allocate 12 independent address bits to the inner entry index just because an inner-table page is 4096 bytes. Entries are 8 bytes each; their byte offsets are aligned, leaving only 9 independent selection bits. The question does not require the entire outer table to fit a single page. Answer: 11.

Original paper, page 44 · Answer key

2 marks · NAT
Report issue

Graph Algorithms

Question 59, GATE 2025: An algorithm runs BFS from any vertex v, picks a farthest vertex u, runs BFS from u, then reports its maximum distance d(u,z). Apply it to the unweighted tree described by these edges (labels added solely to reproduce the source figure): c–l,c–r,c–a,c–b; l–d,l–e,l–g; e–f; g–h,g–i; r–j,r–k; k–m. There are no other edges. Find the reported distance in edges.
Figure orientation: c is the central branching vertex, l its upper-left junction, r its upper-right junction; a,b are the two lower leaves. The left arms end at d,f,h,i and the right arms at j,m.
Tap to enlarge
Answer & solution

Official answer: 6

Step through it (12 steps)

The two-BFS method returns a diameter of an unweighted tree: a farthest vertex from any starting point is a diameter endpoint, and a BFS from that endpoint measures the full diameter. This exact guarantee uses the unique paths of a tree; it should not be assumed for every arbitrary graph.

Compute the diameter directly from the supplied edge list. From central vertex c, the farthest left-side leaves f,h,i are each three edges away: c–l–e–f or c–l–g–h/i. The farthest right-side leaf m is also three edges away: c–r–k–m. Joining a deepest left leaf to m therefore produces a path of length 3+3=6, for example f–e–l–c–r–k–m.

No longer path exists. A path crossing c uses at most two of its branch depths, whose two largest are 3 and 3. A path contained entirely in the left branch has at most 4 edges between f and h/i; a path within the right branch has at most 3 between j and m. The short lower branches of c cannot improve the maximum. Thus the diameter and algorithm's output are 6. The complete 14-vertex, 13-edge tree was reconstructed from the source figure.

Original paper, page 44 · Answer key

2 marks · NAT
Report issue

Finite Automata

Question 60, GATE 2025: Let Σ={1,2,3,4}. For a string x, prod(x) is the product of its symbols modulo 7, with prod(ε)=1. Define L={x:prod(x)=2}. How many states does a minimum DFA for L have?
Tap to enlarge
Answer & solution

Official answer: 6

Step through it (2 parts)

No input symbol is divisible by 7, so a product can never have residue 0. A DFA can keep one of the six nonzero residues 1,…,6 as its state. Start in state 1, use transition δ(r,a)=ra mod 7 for a∈{1,2,3,4}, and accept only state 2. This proves that six states suffice.

To prove minimality, first show all six residues are reachable. Repeated input 3 gives the cycle 1→3→2→6→4→5→1, so every state is reached by some power of the string symbol 3.

Next distinguish two different residues r and s. Nonzero residues modulo the prime 7 have multiplicative inverses. Choose a suffix whose product is t=2r−1 mod 7. Such a suffix exists because powers of 3 realize every nonzero residue. Appending it to a prefix with product r yields rt=2 and is accepted. Appending it to a prefix with product s cannot yield 2: st=rt would imply s=r after cancellation. Thus every pair of reachable states has different residual languages.

By the DFA distinguishability criterion, none of these states can be merged. Exactly six are necessary and sufficient; no seventh zero-residue state is reachable or needed for this alphabet. Answer: 6.

Original paper, page 45 · Answer key

2 marks · NAT
Report issue

Processor Performance

Question 61, GATE 2025: An application takes 6.3 seconds to execute 6.4×10^8 instructions. Instruction classes are: branch CPI 2, count 2.25×10^8; load CPI 5, count 1.20×10^8; store CPI 4, count 1.65×10^8; arithmetic CPI 3, count 1.30×10^8. Find the clock-cycle duration in ns to one decimal place.
Tap to enlarge
Answer & solution

Official answer: 3.0

Multiply each class count by its cycles per instruction before adding. Branches use 2·2.25×108=4.5×108 cycles; loads use 5·1.20×108=6.0×108; stores use 4·1.65×108=6.6×108; arithmetic uses 3·1.30×108=3.9×108. Total cycles are (4.5+6.0+6.6+3.9)×108=2.1×109.

CPU time equals total cycles times cycle duration, so T_cycle=6.3/(2.1×109)=3×10−9 seconds=3.0 ns. Equivalently, the instruction-count-weighted average CPI is 2.1×109/(6.4×108)=3.28125, leading to the same result. A simple arithmetic average of the four CPIs would be incorrect because the instruction counts differ. The corresponding clock frequency is approximately 333.33 MHz, a useful unit check. Answer: 3.0.

Original paper, page 45 · Answer key

2 marks · NAT
Report issue

Pointers & Memory

Question 62, GATE 2025: Find the integer output of this C fragment:
int a; int arr[5]={30,50,10}; int *ptr;
ptr=&arr[0]+1;
a=*ptr;
(*ptr)++;
ptr++;
printf("%d",a+(*ptr)+arr[1]);
Tap to enlarge
Answer & solution

Official answer: 111

Step through it (12 steps)

Array initialization yields arr=[30,50,10,0,0]; omitted entries are zero-initialized. Pointer arithmetic &arr[0]+1 advances by one int element, so ptr initially points to arr[1], whose value is 50. The assignment a=*ptr copies 50 into a.

The parentheses in (*ptr)++ make the increment apply to the pointed-to value. Hence arr[1] becomes 51 while ptr stays at arr[1]. The copied variable a remains 50. The next statement ptr++ instead increments the pointer itself, moving it to arr[2], whose value is 10.

At the print, the three terms are a=50, *ptr=10, and arr[1]=51. Their sum is 50+10+51=111. The operations occur in separate statements, so their sequencing is unambiguous. Confusing (*ptr)++ with *ptr++ would mix up value mutation and pointer advancement and give the wrong trace. Answer: 111.

Original paper, page 46 · Answer key

2 marks · NAT
Report issue

Functions & Parameter Passing

Question 63, GATE 2025: A C program defines g(n)=n+10 and f(n)=g(n*2). It initializes sum=0 and executes for(n=1;n<3;n++) sum += g(f(n)); then prints sum. What integer is printed?
Tap to enlarge
Answer & solution

Official answer: 46

Resolve the function composition from the innermost call outward. Since g(t)=t+10, f(n)=g(2n)=2n+10. Applying g again gives g(f(n))=f(n)+10=2n+20. The two additions of 10 arise from two separate g calls; the outer one does not double its input.

The loop condition is n<3, so it runs for n=1 and n=2 only. At n=1, f(1)=12 and g(f(1))=22, taking sum from 0 to 22. At n=2, f(2)=14 and g(f(2))=24, taking sum to 46. After incrementing n to 3 the condition fails, and no n=3 term is added. The printed value is 46.

Original paper, page 47 · Answer key

2 marks · NAT
Report issue

Probability & Statistics

Question 64, GATE 2025: A monic quadratic over the complex numbers is called square-invariant when (x−α)(x−β)=(x−α²)(x−β²). Choose uniformly from all distinct such polynomials. What is the probability that its two roots are equal? Give one decimal place.
Tap to enlarge
Answer & solution

Official answer: 0.5

Equality of monic polynomials implies equality of their root multisets, including multiplicity: {α,β}={α²,β²}. Squaring must therefore either fix both roots or swap them.

If it fixes each root, α²=α and β²=β, so each root is 0 or 1. Ignoring order, the possible multisets are {0,0},{0,1},{1,1}, giving x², x²−x, and (x−1)².

If it swaps two distinct roots, α²=β and β²=α. Substitute to get α4=α, or α(α³−1)=0. The values α=0 or 1 would force β=α and do not give a distinct swapped pair. The remaining choices are the two nontrivial cube roots of unity ω,ω², which swap under squaring. Together they give one polynomial, (x−ω)(x−ω²)=x²+x+1, because ω+ω²=−1 and ω³=1.

There are therefore four distinct eligible polynomials, not four ordered root pairs. Exactly two, x² and (x−1)², have equal roots. Under uniform choice from these four polynomials, the probability is 2/4=0.5. The complex domain is essential for including x²+x+1. Answer: 0.5.

Original paper, page 47 · Answer key

2 marks · NAT
Report issue

Probability & Statistics

Question 65, GATE 2025: Choose a cut point U uniformly in (0,1), splitting the unit interval into two pieces. Let L be the length of the piece that contains the fixed point 0.4. Find E[L], to two decimal places. The event U=0.4 has probability zero.
Tap to enlarge
Answer & solution

Official answer: 0.70 to 0.80

Our answer: 0.74

Condition on which side of 0.4 the random cut falls. If 0<U<0.4, the point 0.4 belongs to the right piece (U,1), whose length is 1−U. If 0.4<U<1, it belongs to the left piece (0,U), whose length is U. Since U has uniform density 1,
E[L]=∫_00.4(1−u)du + ∫_0.41 u du.

The first integral is [u−u²/2]_00.4=0.4−0.08=0.32. The second is [u²/2]_0.41=0.5−0.08=0.42. Adding them gives 0.74.

Alternatively, conditional means are E[1−U | U<0.4]=1−0.2=0.8 and E[U | U>0.4]=(0.4+1)/2=0.7. Weight by probabilities 0.4 and 0.6 to obtain 0.4·0.8+0.6·0.7=0.74. Do not average the two lengths with equal probability: the containing piece is selected by a fixed location, not by a fair choice between the pieces. The result is within the official range 0.70–0.80. Answer: 0.74.

Original paper, page 48 · Answer key