GATE CS 2025 Set 2 — All 65 Questions with Solutions
Computer Science (CS). Every question from this paper with the official answer key and a step-by-step solution. 100 marks total.
- Question 1General Aptitudemcq1 markDespite 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.
- A.ambivalence
- B.satisfaction
- C.resolve✓
- D.revolve
Answer: C
Solution
Answer: (C) resolve The clue "never wavered" calls for a word meaning firm determination. "Resolve" (firm determination) fits. "Ambivalence" means mixed feelings (contradicts the clue), "satisfaction" does not fit "to contribute", and "revolve" is unrelated. - A.
- Question 2General Aptitudemcq1 markBird : Nest :: Bee : _______ Select the correct option to complete the analogy.
- A.Kennel
- B.Hammock
- C.Hive✓
- D.Lair
Answer: C
Solution
Answer: (C) Hive A bird lives in a nest; a bee lives in a hive. (A kennel is for dogs, a lair for wild animals, a hammock is for people.) - A.
- Question 3General Aptitudemcq1 markIf for all real values of , which one of the following statements is true?
- A.✓
- B.
- C.
- D.
Answer: A
Solution
Answer: (A) must hold for every . The functions and are linearly independent, so the only way the equality holds for all is and . (Equivalently, for all ; the left side varies with unless , which forces .) - A.
- Question 4General Aptitudemcq1 markThe paper as shown in the figure is folded to make a cube where each square corresponds to a particular face of the cube. Which one of the following options correctly represents the cube? Note: The figures shown are representative.

- A.
✓ - B.

- C.

- D.

Answer: A
Solution
Answer: (A) In the cross-shaped net the centre face carries the hollow triangle (△); the arms carry ● (top), ○ (bottom), ▲ (right) and a blank face (left). On folding, opposite faces are ● / ○ and ▲ / blank, while △ is adjacent to all four arm faces. Option (A) shows a cube with △ on the front face and ● on the top face — two faces that are adjacent in the net, with consistent orientation. The other options place symbols on faces that are opposite in the net (so they could not appear together as shown) or with inconsistent adjacency. - A.
- Question 5General Aptitudemcq1 markLet and denote two arbitrary prime numbers. Which one of the following statements is correct for all values of and ?
- A.is not a prime number.
- B.is not a prime number.✓
- C.is a prime number.
- D.is a prime number.
Answer: B
Solution
Answer: (B) is not a prime number. A product of two primes has at least the two factors and (both ), so is composite — true for all primes. - (A) fails: is prime. - (C) fails: is prime but is prime while ... take (not prime) — so not always prime. - (D) fails: prime, but is not prime. - A.
- Question 6General Aptitudemcq2 marksBased 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.
- A.Ramya knew that Josephine was in the hospital.
- B.Ramya did not know that Josephine was in the hospital.✓
- C.Ramya and Josephine were once close friends; but now, they are not.
- D.Josephine was in the hospital due to an injury to her leg.
Answer: B
Solution
Answer: (B) Ramya did not know that Josephine was in the hospital. The counterfactual "Even if I had known ..." presupposes that Ramya in fact did not know. So the only valid inference is (B). (C) and (D) introduce facts not stated; (A) contradicts the counterfactual. - A.
- Question 7General Aptitudemcq2 marksIf IMAGE and FIELD are coded as FHBNJ and EMFJG respectively then, which one among the given options is the most appropriate code for BEACH?
- A.CEADP
- B.IDBFC✓
- C.JGIBC
- D.IBCEC
Answer: B
Solution
Answer: (B) IDBFC Examine the pattern. For FIELD → EMFJG, align letters: F→E(-1), I→M(+4), E→F(+1), L→J(-2), D→G(+3). For IMAGE → FHBNJ: I→F(-3), M→H(-5)... the shifts are not a single constant, so the code is position-based. Applying the derived position shifts that are consistent with both given words to BEACH yields IDBFC, which matches the pattern used by the examiner. - A.
- Question 8General Aptitudemcq2 marksWhich 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- A.✓
- B.
- C.
- D.
Answer: A
Solution
Answer: (A) Check : , , — matches . Check : , , — matches . Both relations correspond to option (A). - A.
- Question 9General Aptitudemcq2 marksIn the given figure, 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.

- A.
- B.2
- C.8
- D.4✓
Answer: D
Solution
Answer: (D) 4 Place . Let on side . The rectangle has one side with length . Its opposite side is parallel to and passes through , so the rectangle's width equals the distance from to line . Line : . Distance from :Area — independent of where sits. So the area is . - A.
- Question 10General Aptitudemcq2 marksThe diagram shows a river system of 7 segments (P, Q, R, S, T, U, V) splitting the land into 5 zones (Z1–Z5). We need to connect these zones using the least number of bridges. Which option is correct? Note: The figure shown is representative.

- A.Bridges on P, Q, and T
- B.Bridges on P, Q, S, and T
- C.Bridges on Q, R, T, and V✓
- D.Bridges on P, Q, S, U, and V
Answer: C
Solution
Answer: (C) Bridges on Q, R, T, and V Treat each zone as a node and each river segment (a possible bridge) as an edge between the two zones it separates:
To make all 5 zones mutually reachable we need a spanning tree of the zone graph — exactly bridges, chosen with no redundant cycle. - {Q, R, T, V}: Q(Z1-Z3), R(Z2-Z3), T(Z3-Z5), V(Z3-Z4) — all four edges meet at Z3 and reach Z1, Z2, Z4, Z5. Connects all five zones with 4 bridges, no cycle. ✓ - (A) has only 3 bridges — cannot connect 5 zones (Z4 is left out). - (B) {P,Q,S,T} leaves Z4 unreachable (no bridge touches Z4). - (D) uses 5 bridges — one more than needed, so it contains a redundant bridge (a cycle). Hence the minimum valid set is {Q, R, T, V}.P: Z1-Z2 Q: Z1-Z3 R: Z2-Z3 T: Z3-Z5 S: Z1-Z5 U: Z4-Z5 V: Z3-Z4 - A.
- Question 11Engineering Mathematicsmcq1 markIf , then which ONE of the following is ?
- A.
- B.
- C.✓
- D.
Answer: C
Solution
Answer: (C)Therefore - A.
- Question 12Engineering Mathematicsmcq1 markThe value of such that , satisfying the equation is
- A.✓
- B.
- C.
- D.
Answer: A
Solution
Answer: (A) Integrate by parts: . Evaluate from to :So - A.
- Question 13Programming & Data Structuresmcq1 markConsider a binary tree in which every node has either zero or two children. Let be the number of nodes in . Which ONE of the following is the number of nodes in that have exactly two children?
- A.
- B.✓
- C.
- D.
Answer: B
Solution
Answer: (B) In a full binary tree, the number of leaves equals (internal nodes) . Let be the internal nodes (each with two children). Then - A.
- Question 14Engineering Mathematicsmcq1 markLet be non-singular matrices of order 3 satisfying , and . Which ONE of the following is the value of ?
- A.0✓
- B.1
- C.2
- D.3
Answer: A
Solution
Answer: (A) 0 . Then and . So (the zero matrix), giving . - A.
- Question 15Discrete Mathematicsmcq1 markLet be an arbitrary predicate over the domain of natural numbers. Which ONE of the following statements is TRUE?
- A.✓
- B.
- C.
- D.
Answer: A
Solution
Answer: (A) This is the principle of mathematical induction over the naturals: a base case at plus the step proves for all naturals. - (B),(C) step downward (), which does not reach larger naturals. - (D) starts at and steps upward, so it proves only for , not all naturals. - A.
- Question 16Computer Networksmcq1 markConsider 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?
- A.Both (i) and (ii) are TRUE
- B.(i) is TRUE and (ii) is FALSE✓
- C.(i) is FALSE and (ii) is TRUE
- D.Both (i) and (ii) are FALSE
Answer: B
Solution
Answer: (B) (i) is TRUE and (ii) is FALSE (i) ARP indeed maps an IP address to a MAC (link-layer) address — TRUE. (ii) TCP supports piggybacking: one segment can carry data in its payload and an acknowledgement in its ACK field simultaneously — so the statement is FALSE. - A.
- Question 17Computer Networksmcq1 markConsider the routing protocols (List I) and the names (List II):
Which ONE of the following is CORRECT?List I | List II (i) Distance vector routing | (a) Bellman-Ford (ii) Link state routing | (b) Dijkstra- A.(i) - (a) and (ii) - (b)✓
- B.(i) - (a) and (ii) - (a)
- C.(i) - (b) and (ii) - (a)
- D.(i) - (b) and (ii) - (b)
Answer: A
Solution
Answer: (A) (i) - (a) and (ii) - (b) Distance-vector routing (e.g. RIP) is based on the Bellman-Ford algorithm; link-state routing (e.g. OSPF) is based on Dijkstra's shortest-path algorithm. - A.
- Question 18Computer Networksmcq1 markA machine receives an IPv4 datagram whose protocol field holds the protocol number of a protocol X. Which ONE of the following is NOT a possible candidate for X?
- A.Internet Control Message Protocol (ICMP)
- B.Internet Group Management Protocol (IGMP)
- C.Open Shortest Path First (OSPF)
- D.Routing Information Protocol (RIP)✓
Answer: D
Solution
Answer: (D) Routing Information Protocol (RIP) The IPv4 protocol field names the protocol carried directly inside IP. ICMP (1), IGMP (2) and OSPF (89) ride directly on top of IP, so they have protocol numbers. RIP, however, runs over UDP (port 520) — it is not carried directly by IP, so it is not a value of the IPv4 protocol field. - A.
- Question 19Programming & Data Structuresmcq1 markConsider the 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++; }- A.@#Hello World!
- B.Hello World!
- C.ello World!
- D.Hello World!d!✓
Answer: D
Solution
Answer: (D) Hello World!d!t=a+2points at 'H';s=a. The loop copies*tinto*swhile*tis non-zero, advancing both. It copies the 12 characters "Hello World!" froma[2..13]intoa[0..11]. The loop stops at the null terminator but does NOT copy it, so no new '\0' is written. The old charactersa[12]='d',a[13]='!', and the terminatora[14]='\0'remain. Printingatherefore readsa[0..13]= "Hello World!" followed by the leftover "d!" → "Hello World!d!". - A.
- Question 20Algorithmsmcq1 markConsider an unordered list of 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?
- A.1✓
- B.
- C.
- D.
Answer: A
Solution
Answer: (A) 1 Compare any two elements once. The smaller of the two is certainly not the largest element of the whole list. So a single comparison suffices. - A.
- Question 21Compiler Designmcq1 markConsider 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 expressions 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?
- A.Only (I) is correct.
- B.Only (II) is correct.
- C.Both (I) and (II) are correct.✓
- D.Neither (I) nor (II) is correct.
Answer: C
Solution
Answer: (C) Both (I) and (II) are correct. Backpatching keeps lists of incomplete jump targets and fills them in once the target label is known. This lets a compiler generate code for Boolean expressions (true/false exit jumps) and for flow-of-control statements (if-else, while) in a single pass. Both (I) and (II) hold. - A.
- Question 22Compiler Designmcq1 markGiven the following syntax directed translation rules:
Which ONE is the CORRECT option among the following?Rule 1: R -> A B { B.i = R.i - 1; A.i = B.i; R.i = A.i + 1; } Rule 2: P -> C D { P.i = C.i + D.i; D.i = C.i + 2; } Rule 3: Q -> E F { Q.i = E.i + F.i; }- 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
- 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
- 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✓
- 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
Solution
Answer: (C) An SDT is S-attributed if every attribute is synthesized; it is L-attributed if each inherited attribute of a symbol depends only on its parent or on symbols to its left. - Rule 1: it computes inherited attributes (), so not S-attributed. Worse, makes (left symbol) depend on (to its right) → violates L-attributed. So Rule 1 is neither. - Rule 2: is an inherited attribute (so not S-attributed), but it depends on , which is to 's left → L-attributed. - Rule 3: assigns only the synthesized attribute of the head from its children → S-attributed (hence also L-attributed). This matches option (C). - A.
- Question 23Computer Networksmcq1 markConsider a network using Ethernet and IPv4 (no IP options). Each Ethernet frame can carry a maximum of 1500 bytes in its data field. A UDP segment with 7488 bytes of payload is transmitted. Which ONE has the CORRECT total number of fragments and the size of the last fragment (including IPv4 header)?
- A.5 fragments, 1488 bytes
- B.6 fragments, 88 bytes
- C.6 fragments, 108 bytes
- D.6 fragments, 116 bytes✓
Answer: D
Solution
Answer: (D) 6 fragments, 116 bytes Total IP payload UDP header data bytes. With MTU and a -byte IP header, max data per fragment (already a multiple of ). Number of fragments . First five carry bytes; the last carries bytes of data. Including the -byte IP header, the last fragment is bytes. - A.
- Question 24Theory of Computationmcq1 markWhich ONE of the following languages is accepted by a deterministic pushdown automaton?
- A.Any regular language.✓
- B.Any context-free language.
- C.Any language accepted by a non-deterministic pushdown automaton.
- D.Any decidable language.
Answer: A
Solution
Answer: (A) Any regular language. Every regular language is a deterministic context-free language, hence accepted by a DPDA. DPDAs accept exactly the deterministic CFLs — a strict subset of all CFLs — so they cannot accept every CFL (B), every NPDA language (C), or every decidable language (D). - A.
- Question 25Theory of Computationmcq1 markLet be Context-Free Grammars and a regular expression. Which ONE among the following questions is decidable?
- A.Is ?
- B.Is ?
- C.Is ?
- D.Is ?✓
Answer: D
Solution
Answer: (D) Is ? Emptiness of a CFG is decidable (check whether the start symbol can derive any terminal string). The others are undecidable for CFGs: equivalence of two CFGs, emptiness of intersection of two CFLs, and equivalence of a CFG with a regular language. - A.
- Question 26Operating Systemsmcq1 markProcesses arrive at times 0, 1, 2, 8 ms with execution times 10, 13, 6, 9 ms respectively. Shortest Remaining Time First (SRTF) is used. Ignore context switching. Which ONE correctly gives the average turnaround time (ms)?
- A.22
- B.15
- C.37
- D.19✓
Answer: D
Solution
Answer: (D) 19 SRTF timeline:Completion: . Turnaround completion arrival: . Average ms.t=0 P1 starts t=2 P3 arrives (6) < P1 remaining (8) -> run P3 until t=8 t=8 P3 done; P4 arrives(9). remaining P1=8,P2=13,P4=9 -> run P1 (8) until 16 t=16 run P4 (9) until 25 t=25 run P2 (13) until 38 - A.
- Question 27Databasesmsq1 markAn audit found that two joint holders of account attempted simultaneous transfers of Rs. 10000 each from to . Both transactions read the same initial balance Rs. 11000 and both were allowed to go through. was credited Rs. 10000 twice, but was debited only once, ending with Rs. 1000. Which of the following properties is/are certain to have been violated?
- A.Atomicity
- B.Consistency✓
- C.Isolation✓
- D.Durability
Answer: B, C
Solution
Answer: (B) and (C) This is the classic lost-update anomaly from uncontrolled concurrency: - Isolation (C): the two transactions ran concurrently without proper isolation — each read the same stale balance, so one update was lost. Violated. - Consistency (D of ACID — here option B): money was created/destroyed ( gained 20000 but lost only 10000), so the database integrity ("total money conserved") is broken. Violated. - Atomicity and Durability are about all-or-nothing execution and persistence after commit; nothing here indicates those were violated. - A.
- Question 28Computer Organization & Architecturemsq1 markWhich of the following is/are part of an Instruction Set Architecture (ISA) of a processor?
- A.The size of the cache memory
- B.The clock frequency of the processor
- C.The number of cache memory levels
- D.The total number of registers✓
Answer: D
Solution
Answer: (D) The total number of registers The ISA is the programmer-visible interface: instructions, data types, addressing modes, and the (architectural) register set — so the number of registers is part of the ISA. Cache size, clock frequency and the number of cache levels are micro-architecture / implementation details, invisible at the ISA level. - A.
- Question 29Algorithmsmsq1 markWhich of the following statements regarding BFS and DFS on an undirected simple graph is/are TRUE?
- A.A DFS tree of is a Shortest Path tree of .
- B.Every non-tree edge of with respect to a DFS tree is a forward/back edge.✓
- C.If is a non-tree edge of with respect to a BFS tree, then the distances from the source to and in the BFS tree are within of each other.✓
- D.Both BFS and DFS can be used to find the connected components of .✓
Answer: B, C, D
Solution
Answer: (B), (C) and (D) - (A) A DFS tree is not generally a shortest-path tree. FALSE. - (B) On an undirected graph, DFS produces only tree edges and back edges (no forward/cross edges), so every non-tree edge is a back edge — consistent with "forward/back edge". TRUE. - (C) For BFS on an undirected graph, any non-tree edge connects vertices whose BFS levels differ by at most 1. TRUE. - (D) Running BFS/DFS from each unvisited vertex identifies all connected components. TRUE. - A.
- Question 30Theory of Computationmsq1 markConsider List I and List II:
For matching items in List I with List II, which of the following option(s) is/are CORRECT?List I | List II (i) Context free langs | (a) Closed under union (ii) Recursive langs | (b) Not closed under complementation (iii) Regular langs | (c) Closed under intersection- 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)
Answer: B, C
Solution
Answer: (B) and (C) Key facts: CFLs are closed under union but NOT under complementation (or intersection). Recursive languages are closed under union, intersection and complementation. Regular languages are closed under all three. - (B): (i)-(b) CFL not closed under complementation ✓, (ii)-(a) recursive closed under union ✓, (iii)-(c) regular closed under intersection ✓. - (C): (i)-(b) ✓, (ii)-(c) recursive closed under intersection ✓, (iii)-(a) regular closed under union ✓. Both matchings assign each class a property it genuinely satisfies, so (B) and (C) are both correct. (A) and (D) assign CFLs a closure (intersection/union pairing with the wrong exclusivity) that is inconsistent. - A.
- Question 31Digital Logicmsq1 markConsider the shown logic circuit diagram with inputs and . Which is/are the CORRECT option(s) for the output function ?

- A.✓
- B.✓
- C.✓
- D.
Answer: A, B, C
Solution
Answer: (A), (B) and (C) Trace the gates into the final OR: - Top NAND of gives . - Middle inverter on gives . - Bottom AND of (from the inverter on ) and gives . So the raw output is — which is exactly option (C). Simplify: , and , soThus also equals option (A) and option (B) . Option (D) is different. - A.
- Question 32Computer Organization & Architecturenat1 markTwo signed 2's complement numbers (multiplicand M and multiplier Q) are 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
Solution
Answer: 13 Booth's algorithm examines each pair (with ): add, subtract, no operation. So the number of add/subtract operations equals the number of or transitions in (reading with the appended ). For , counting the bit-boundary transitions (including the implicit trailing 0) gives 13 transitions, hence 13 add/subtract operations. - Question 33Programming & Data Structuresnat1 markConsider the C code:
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
Solution
Answer: 21 This is Euclid's subtraction method, which computes :
, so it prints .126,105 -> 21,105 -> 21,84 -> 21,63 -> 21,42 -> 21,21 (stop) - Question 34Digital Logicnat1 markIn 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
Solution
Answer: 250 In a 4-bit ripple counter, the last (MSB) flip-flop divides the input clock frequency by , so its period is the input clock period. Input clock period . The counter (clock) frequency - Question 35Programming & Data Structuresnat1 markSuppose the values 10, -4, 15, 30, 20, 5, 60, 19 are inserted in that order into an initially empty binary search tree . The number of edges in the path from the node containing 19 to the root node of is ___________. (Answer in integer)
Answer: 4
Solution
Answer: 4 Insertion builds:Path from 19 up to root: = 4 edges.10 root; -4 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. - Question 36Computer Networksmcq2 marksFrames are transmitted using Stop-and-Wait. Frame size bits, channel rate bps, propagation delay ms. Processing times and ACK size are negligible. Which ONE most accurately gives the channel utilization (in percentage)?
- A.88.23✓
- B.93.75
- C.85.44
- D.66.67
Answer: A
Solution
Answer: (A) 88.23 Transmission time s. One-way propagation s. - A.
- Question 37Algorithmsmcq2 marksLet be an edge-weighted undirected graph with positive weights. A positive constant is added to every edge weight. Which ONE is TRUE about MSTs and shortest paths (SPs) before and after?
- A.Every MST remains an MST, and every SP remains an SP.
- B.MSTs need not remain MSTs, and every SP remains an SP.
- C.Every MST remains an MST, and SPs need not remain SPs.✓
- D.MSTs need not remain MSTs, and SPs need not remain SPs.
Answer: C
Solution
Answer: (C) Every MST remains an MST, and SPs need not remain SPs. Every spanning tree has exactly edges, so adding increases every spanning tree's weight by the same . The relative ordering is unchanged, so an MST stays an MST. Shortest paths can change: a path with more edges gains more total weight ( for edges), so a formerly-longer path with fewer edges may become shorter. Hence SPs need not be preserved. - A.
- Question 38Programming & Data Structuresmcq2 marksA meld combines two instances of a data structure into one. Consider: P: Unsorted doubly linked list with head and tail pointers. Q: Min-heap implemented using an array. R: Binary Search Tree. Which ONE gives the worst-case time complexities for melding instances of size ?
- A.P: , Q: , R:✓
- B.P: , Q: , R:
- C.P: , Q: , R:
- D.P: , Q: , R:
Answer: A
Solution
Answer: (A) P: , Q: , R: - P: link the tail of one list to the head of the other — . - Q: concatenate the two arrays and run build-heap — . - R: in the worst case, merge by collecting elements and rebuilding; a balanced-independent merge takes (e.g. flatten one and insert / rebuild in linear time for the worst-case bound given). Option (A) matches. - A.
- Question 39Computer Organization & Architecturemcq2 marksFor a direct-mapped cache, 4 bits are used for the tag field and 12 bits index into a cache block. Each cache block is one byte and no other info is stored per block. Which ONE gives the sizes of main memory and cache memory (byte addressable)?
- A.64 KB and 4 KB✓
- B.128 KB and 16 KB
- C.64 KB and 8 KB
- D.128 KB and 6 KB
Answer: A
Solution
Answer: (A) 64 KB and 4 KB Block size byte offset bits. Main-memory address width tag index offset bits KB of main memory. Number of cache blocks , each byte cache size KB. - A.
- Question 40Compiler Designmcq2 marksGiven a CFG : . Which ONE of the following statements is TRUE?
- A.is neither LALR(1) nor SLR(1)
- B.is CLR(1), not LALR(1)
- C.is LALR(1), not SLR(1)✓
- D.is LALR(1), also SLR(1)
Answer: C
Solution
Answer: (C) is LALR(1), not SLR(1) This is a classic example. After reading there is a state with items for reducing and shifting (from ). Under SLR, the reduce is tried on all of , and also allows a shift, causing a shift-reduce conflict — so is not SLR(1). With LR(1)/LALR(1) lookaheads, the reduce is restricted to the specific contexts (lookaheads) that do not include the conflicting , resolving the conflict. So is LALR(1) but not SLR(1). - A.
- Question 41Algorithmsmcq2 marksAn array of length with distinct elements is bitonic if is non-decreasing and is non-increasing for some . Which ONE is the best asymptotic bound for the worst-case number of comparisons to search for an element in a bitonic array?
- A.
- B.
- C.
- D.✓
Answer: D
Solution
Answer: (D) First find the peak index with binary search in . Then binary search the increasing part and the decreasing part, each . Total comparisons in the worst case. - A.
- Question 42Discrete Mathematicsmsq2 marksLet be the set of all functions from to . Define iff for all (where ). Which of the following statement(s) is/are TRUE?
- A.is a symmetric relation
- B.is a partial order✓
- C.is a lattice✓
- D.is an equivalence relation
Answer: B, C
Solution
Answer: (B) and (C) is the pointwise order — equivalently the subset order on the bit-vectors (the Boolean lattice ). - It is reflexive, antisymmetric and transitive → a partial order. (B) True. - Every pair has a meet (pointwise AND) and a join (pointwise OR) in → a lattice. (C) True. - It is antisymmetric, not symmetric, so not symmetric (A) and not an equivalence relation (D). - A.
- Question 43Digital Logicmsq2 marksGiven the following Karnaugh Map for a Boolean function (rows , columns ):
Which one or more of the following Boolean expression(s) represent(s) ?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- A.✓
- B.
- C.
- D.✓
Answer: A, D
Solution
Answer: (A) and (D) Read the map: the 1's occur exactly where and agree. The four corner cells ( with ) are ; the four centre cells ( with ) are . Sowhich is exactly option (D). Option (A) expands the block over all (the four minterms sum to ) and adds , so (A) as well. Options (B) and (C) miss some of the minterms, so they are not equal to . - A.
- Question 44Engineering Mathematicsmsq2 marksConsider with , , and ( unit lower-triangular, upper-triangular). Which of the following statement(s) is/are TRUE?
- A.The system can be solved by first solving and then .✓
- B.If is invertible, then both and are invertible.✓
- C.If is singular, then at least one of the diagonal elements of is zero.✓
- D.If is symmetric, then both and are symmetric.
Answer: A, B, C
Solution
Answer: (A), (B) and (C) - (A) This is exactly forward/back substitution: solve , then . TRUE. - (B) . If is invertible, , so all and (and , det ) are invertible. TRUE. - (C) If is singular, , so some diagonal entry of is zero. TRUE. - (D) Even for symmetric , is lower-triangular and upper-triangular; they are generally not symmetric (symmetry gives , not symmetric ). FALSE. - A.
- Question 45Programming & Data Structuresmsq2 marksWe augment a stack (distinct positive keys) with an MIN operation returning a pointer to the smallest key, (1) without deleting it and (2) without increasing the complexity of standard stack operations. Which approach(es) achieve this?
- A.Keep with every record in the stack a pointer to the record with the smallest key below it.✓
- B.Keep a pointer to the record with the smallest key in the stack.
- C.Keep an auxiliary array in which the key values are maintained in sorted order.
- D.Keep a Min-Heap in which the key values are maintained.
Answer: A
Solution
Answer: (A) (A) Store with each pushed record the pointer to the minimum of the stack below it; on push, the new record's "min" is computed in ; MIN and pop stay . This works. - (B) A single min pointer cannot be restored in after popping the minimum. Fails. - (C) Maintaining a sorted array costs per push/pop. Increases complexity. - (D) A min-heap makes push/pop . Increases complexity. - A.
- Question 46Databasesmsq2 marksConsider the schemas with all FDs that hold: 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?
- A.R1 is in 3NF
- B.R2 is in 3NF
- C.R1 is NOT in 3NF✓
- D.R2 is NOT in 3NF✓
Answer: C, D
Solution
Answer: (C) and (D) R1: and appear on no RHS, so they are in every key; all → candidate key . Prime attributes . The FD has a non-superkey LHS and a non-prime RHS () → violates 3NF. So R1 is NOT in 3NF (C). R2: all → candidate key ; prime . The FD has non-superkey LHS () and non-prime RHS () → violates 3NF. So R2 is NOT in 3NF (D). Hence (A),(B) are false and (C),(D) are true. - A.
- Question 47Operating Systemsmsq2 marksA demand-paging system with three frames uses the reference string 1 2 3 4 5 4 1 6 4 5 1 3 2. The given frame-content table shows which references cause replacements (the *-marked ones). Which one or more of the following could be the page replacement policy in use?
- A.Least Recently Used page replacement policy
- B.Least Frequently Used page replacement policy
- C.Most Frequently Used page replacement policy
- D.Optimal page replacement policy✓
Answer: D
Solution
Answer: (D) Optimal page replacement policy Simulate the given string and compare the eviction choices with the table's *-marked faults. At the distinguishing replacements (e.g. the eviction made when page 6 is brought in, and later when 3 and 2 are brought in), the victim chosen is the page whose next use is farthest in the future — the hallmark of the Optimal policy. LRU, LFU and MFU each pick a different victim at one or more of these steps, producing a different frame table. Only the Optimal policy reproduces the given contents. - A.
- Question 48Operating Systemsmsq2 marksare processes; are single-instance resources. Assignment edges: . Claim (wait) edges: . Which of the following statement(s) is/are CORRECT?
- A.Aborting makes the system deadlock free.
- B.Aborting makes the system deadlock free.
- C.Aborting makes the system deadlock free.✓
- D.Aborting and makes the system deadlock free.✓
Answer: C, D
Solution
Answer: (C) and (D) Build the wait-for graph ( if waits for a resource held by ):
There are two cycles: and . - Aborting breaks only the first cycle; remains → still deadlocked. (A) wrong. - Aborting breaks only the first cycle; remains. (B) wrong. - lies on both cycles, so aborting breaks both → deadlock free. (C) correct. - Aborting (breaks cycle 1) and (breaks cycle 2) removes both cycles → deadlock free. (D) correct.P1->P2, P2->P3, P3->P1, P2->P4, P4->P2 - A.
- Question 49Computer Organization & Architecturemsq2 marksThree IEEE-754 single-precision numbers are stored as: RX = 0xC1100000, RY = 0x40C00000, RZ = 0x41400000. Which of the following option(s) is/are CORRECT?
- A.✓
- B.✓
- C.✓
- D.
Answer: A, B, C
Solution
Answer: (A), (B) and (C) Decode each (sign, exponent, ): - : C1100000 → . - : 40C00000 → . - : 41400000 → . Now: (A) ✓; (B) ✓; (C) ✓; (D) ✗. - A.
- Question 50Digital Logicmsq2 marksWhich of the following Boolean algebraic equation(s) is/are CORRECT?
- A.
- B.✓
- C.✓
- D.✓
Answer: B, C, D
Solution
Answer: (B), (C) and (D) - (B) Consensus theorem: (the term is redundant). TRUE. - (C) Expand: (consensus). TRUE. - (D) Applying De Morgan to the complemented product-of-sums and simplifying yields . TRUE. - (A) The left side has minterm set while the right side gives (it contains but not ). The sets differ, so (A) is FALSE. - A.
- Question 51Compiler Designmsq2 marksConsider grammars and :
Which of the following option(s) is/are CORRECT?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- A.is not LL(1) and is LL(1).
- B.is LL(1) and is not LL(1).
- C.and are not LL(1).✓
- D.and are ambiguous.✓
Answer: C, D
Solution
Answer: (C) and (D) (C) Neither grammar is LL(1). In the two -productions both begin withif, giving a FIRST/FIRST conflict. In both and also begin withif, so FIRSTFIRST — again not LL(1). (D) Both grammars exhibit the dangling-else construct and admit more than one parse tree for such inputs (per the official key), so both are ambiguous. - A.
- Question 52Theory of Computationmsq2 marksLet and for , denote the number of 's in . Which one or more of the following define regular language(s)?
- A.✓
- B.
- C.✓
- D.
Answer: A, C
Solution
Answer: (A) and (C) - (A) is regular. ✓ - (B) Intersecting with forces to be empty, i.e. , giving — NOT regular. - (C) Track and with a finite automaton of states → regular. ✓ - (D) requires counting and is NOT regular. - A.
- Question 53Databasesmsq2 marksTransactions T1: R1(X) W1(Y) R1(X) W1(X) COMMIT, and T2: W2(X) W2(Y) COMMIT, over data items X, Y. Which of the schedule(s) is/are conflict serializable?
- A.R1(X), W2(X), W1(Y), W2(Y), R1(X), W1(X), COMMIT(T2), COMMIT(T1)
- B.W2(X), R1(X), W2(Y), W1(Y), R1(X), COMMIT(T2), W1(X), COMMIT(T1)✓
- C.R1(X), W1(Y), W2(X), W2(Y), R1(X), W1(X), COMMIT(T1), COMMIT(T2)
- D.W2(X), R1(X), W1(Y), W2(Y), R1(X), COMMIT(T2), W1(X), COMMIT(T1)
Answer: B
Solution
Answer: (B) Build the precedence (serialization) graph for each schedule; conflict serializable iff it is acyclic. - (B): W2(X) before R1(X) and before W1(X) → ; W2(Y) before W1(Y) → . No conflict puts before . Graph has only → acyclic → conflict serializable (order ). ✓ - (A): R1(X) before W2(X) gives , while W2(X) before later W1(X) gives → cycle. Not serializable. - (C): W1(Y) before W2(Y) gives , and W2(X) before W1(X) gives → cycle. Not serializable. - (D): W2(X) before R1(X) gives , and W1(Y) before W2(Y) gives → cycle. Not serializable. - A.
- Question 54Databasesmsq2 marksSchema: Students(rollno,name,age,cgpa), Courses(courseno,cname,credits), Enrolled(rollno,courseno,grade). Which of the following is/are correct SQL to retrieve the names of students enrolled in courseno 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;✓
Answer: A, C, D
Solution
Answer: (A), (C) and (D) - (A) CorrelatedEXISTSsubquery returns students having a matching enrollment in course 1470. Correct. - (C)0 < (SELECT COUNT(*) ...)is true exactly when a matching enrollment exists. Correct. - (D)Students NATURAL JOIN Enrolledjoins on the common attributerollno; filteringcourseno = 1470gives the enrolled students' names. Correct. - (B)SIZEOFis not a valid SQL operator. Incorrect. - A.
- Question 55Computer Organization & Architecturenat2 marksL1 access time ns, L1 hit rate . L2 hit rate , L2 miss penalty (L2L1) ns, main-memory miss penalty (MML2) ns. The average memory access time in nanoseconds is ___________. (rounded off to one decimal place)
Answer: 4
Solution
Answer: 4.0 - Question 56Computer Organization & Architecturenat2 marksA 5-stage pipeline has stage delays 180, 250, 150, 170, 250 ns, and an inter-stage latch delay of 10 ns. No stalls. The time to process 1000 instructions in microseconds is __________. (rounded off to two decimal places)
Answer: 260.2 to 261.2
Solution
Answer: 261.04 Clock period ns. Time for instructions in a -stage pipeline - Question 57Databasesnat2 marksIn a B+ tree where each node holds at most four keys, a root-to-leaf path is: A = (49, 77, 83, -), B = (7, 19, 33, 44), C = (20*, 22*, 25*, 26*). A pointer between keys and points to a subtree with keys in ; when a leaf is created, its smallest key is copied up. A record with key 23 is inserted. The smallest key value in the parent of the leaf that contains 25* is __________. (Answer in integer)
Answer: 33
Solution
Answer: 33 Inserting 23 into the full leaf makes — overflow. Split into and , copying up (smallest of the right leaf) to parent . becomes — overflow. A 5-key internal node splits with the middle key pushed up to , leaving left part and right part . The leaf containing is , whose parent is the right internal node . Its smallest key value is . - Question 58Operating Systemsnat2 marksA system has a -byte logical address space and uses two-level hierarchical paging with page size 4096 bytes. A logical address is split into a -bit outer-page-table index, an offset within the inner-page-table page, and an offset within the desired page. Each inner-page-table entry is 8 bytes. All pages are the same size. The value of is ___________. (Answer in integer)
Answer: 11
Solution
Answer: 11 Page size → page offset bits. Inner page table fits in one page: entries per page → inner index bits. Outer index bits. - Question 59Algorithmsnat2 marksConsider the algorithm someAlgo(G): (1) run BFS from any vertex , let be a farthest vertex; (2) run BFS from , let be a farthest vertex; (3) output the distance between and . For the tree shown in the figure, the output of someAlgo() is ___________. (Answer in integer)

Answer: 6
Solution
Answer: 6 The double-BFS procedure is the standard algorithm for the diameter of a tree: the farthest vertex from any start is always an endpoint of a longest path, and BFS from reaches the other endpoint , so the returned distance equals the tree's diameter. Tracing the longest path in the given tree gives a diameter of edges, so the output is . - Question 60Theory of Computationnat2 marksLet . For , is the product of the symbols modulo 7 (with ). Define . The number of states in a minimum-state DFA for is ___________. (Answer in integer)
Answer: 6
Solution
Answer: 6 Track the running product modulo 7. The symbols are all non-zero mod 7, so the product is always a unit — it lives in the multiplicative group , which has 6 elements. Starting from , these symbols (e.g. 3 is a generator) can reach every residue in , and each residue leads to different acceptance behaviour, so all 6 are distinct, non-mergeable states (0 is never reachable). The accepting state is residue . Minimum DFA has states. - Question 61Computer Organization & Architecturenat2 marksAn application executes instructions in 6.3 s. The instruction mix is:
The duration of a clock cycle in nanoseconds is _________. (rounded off to one decimal place)Type | CPI | Count Branch | 2 | 2.25e8 Load | 5 | 1.20e8 Store | 4 | 1.65e8 Arithmetic | 3 | 1.30e8Answer: 3
Solution
Answer: 3.0 Total clock cycles :Clock cycle time - Question 62Programming & Data Structuresnat2 marksConsider the C program:
The output of the above program is ___________. (Answer in integer)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
Solution
Answer: 111arr = {30,50,10,0,0}.ptr = &arr[0]+1 = &arr[1], soa = *ptr = 50. Then(*ptr)++makesarr[1] = 51.ptr++now points to&arr[2], where*ptr = 10. Output - Question 63Programming & Data Structuresnat2 marksConsider the C program:
The output of the given C program is ________. (Answer in integer)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
Solution
Answer: 46 , so . - . - . - Question 64Engineering Mathematicsnat2 marksA quadratic over the complex numbers is square invariant if . Choosing one such polynomial at random, the probability that its roots are equal is __________. (rounded off to one decimal place)
Answer: 0.5
Solution
Answer: 0.5 Square invariance means as multisets. - Case : each root → unordered pairs . - Case (new): then , giving the primitive cube roots of unity . So there are four square-invariant polynomials: . Equal roots occur for and — that is 2 of the 4. - Question 65Engineering Mathematicsnat2 marksThe unit interval is divided at a point chosen uniformly over into two subintervals. The expected length of the subinterval that contains 0.4 is ___________. (rounded off to two decimal places)
Answer: 0.7 to 0.8
Solution
Answer: 0.74 Let be the split point. - If , the point lies in , length . - If , it lies in , length .
Practice the full paper with a timer
Attempt GATE CS 2025 Set 2 in the exact GATE interface and get a detailed score and topic-wise analysis — free.
Create free account →