GATE CS 2025 Set 1 — 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 markRavi had ______ younger brother who taught at ______ university. He was widely regarded as ______ honorable man. Select the option with the correct sequence of articles to fill in the blanks.
- A.a; a; an✓
- B.the; an; a
- C.a; an; a
- D.an; an; a
Answer: A
Solution
Answer: (A) a; a; an Articles depend on the sound that follows, not the spelling. - "younger" starts with a consonant sound /j/ → "a". - "university" starts with a consonant sound /ju:/ → "a". - "honorable" starts with a vowel sound (silent h) → "an". So the sequence is "a; a; an". - A.
- Question 2General Aptitudemcq1 markThe CEO's decision to downsize the workforce was considered myopic because it sacrificed long-term stability to accommodate short-term gains. Select the most appropriate option that can replace the word "myopic" without changing the meaning of the sentence.
- A.visionary
- B.shortsighted✓
- C.progressive
- D.innovative
Answer: B
Solution
Answer: (B) shortsighted "Myopic" literally means near-sighted; figuratively it means lacking foresight. The sentence confirms this ("sacrificed long-term stability ... for short-term gains"). The synonym is "shortsighted". "Visionary", "progressive" and "innovative" all mean the opposite (forward-looking). - A.
- Question 3General Aptitudemcq1 markThe average marks obtained by a class in an examination were calculated as . However, while checking the marks entered, the teacher found that the marks of one student were entered incorrectly as instead of . After correcting the marks, the average becomes . How many students does the class have?
- A.25
- B.28
- C.30✓
- D.32
Answer: C
Solution
Answer: (C) 30 The total increases by after correction. This raised the average by . If is the number of students, the extra marks are spread over students: - A.
- Question 4General Aptitudemcq1 markConsider the relationships among P, Q, R, S, and T: - P is the brother of Q. - S is the daughter of Q. - T is the sister of S. - R is the mother of Q. The following statements are made based on the relationships given above. (1) R is the grandmother of S. (2) P is the uncle of S and T. (3) R has only one son. (4) Q has only one daughter. Which one of the following options is correct?
- A.Both (1) and (2) are true.✓
- B.Both (1) and (3) are true.
- C.Only (3) is true.
- D.Only (4) is true.
Answer: A
Solution
Answer: (A) Both (1) and (2) are true. - R is mother of Q, and Q is parent of S → R is the grandmother of S. (1) True. - P is brother of Q, and Q is parent of S and T → P is the uncle of S and T. (2) True. - (3) R has only one son: P is a son of R, but Q's sex is not given; Q could also be a son. Not guaranteed → not necessarily true. - (4) Q has only one daughter: Q has two daughters, S and T (T is the sister of S) → False. So only (1) and (2) are guaranteed. - A.
- Question 5General Aptitudemcq1 markAccording to the map shown in the figure, which one of the following statements is correct? Note: The figure shown is representative.

- A.The library is located to the northwest of the canteen.
- B.The hospital is located to the east of the chemistry lab.
- C.The chemistry lab is to the southeast of physics lab.✓
- D.The classrooms and canteen are next to each other.
Answer: C
Solution
Answer: (C) The chemistry lab is to the southeast of physics lab. The two roads divide the map into four quadrants (compass: N up, E right): - NW: Library, Physics Lab - NE: Canteen, Hospital - SW: Hostels, Classrooms - SE: Chemistry Lab Physics Lab is in the NW block and Chemistry Lab is in the SE block → the chemistry lab is southeast of the physics lab. (C) is correct. - (A) Library and Canteen are in the same (top) row → library is west, not north-west, of the canteen. - (B) Hospital (NE) is to the north of the chemistry lab (SE), not east. - (D) Classrooms (SW) and Canteen (NE) are in opposite corners, not next to each other. - A.
- Question 6General Aptitudemcq2 marks"I put the brown paper in my pocket along with the chalks, and possibly other things. I suppose every one must have reflected how primeval and how poetical are the things that one carries in one's pocket: the pocket-knife, for instance the type of all human tools, the infant of the sword. Once I planned to write a book of poems entirely about the things in my pocket. But I found it would be too long: and the age of the great epics is past." (From G.K. Chesterton's "A Piece of Chalk") Based only on the information provided in the above passage, which one of the following statements is true?
- A.The author of the passage carries a mirror in his pocket to reflect upon things.
- B.The author of the passage had decided to write a poem on epics.
- C.The pocket-knife is described as the infant of the sword.✓
- D.Epics are described as too inconvenient to write.
Answer: C
Solution
Answer: (C) The pocket-knife is described as the infant of the sword. The passage literally states: the pocket-knife is "the type of all human tools, the infant of the sword." So (C) is directly supported. - (A) "reflected" is used figuratively (to ponder); there is no mirror. - (B) He planned a book of poems about the things in his pocket, not about epics. - (D) The book of poems would be "too long"; he does not call epics inconvenient to write. - A.
- Question 7General Aptitudemcq2 marksIn the diagram, the lines QR and ST are parallel to each other. The shortest distance between these two lines is half the shortest distance between the point P and line QR. What is the ratio of the area of the triangle PST to the area of the trapezium SQRT? Note: The figure shown is representative.

- A.✓
- B.
- C.
- D.
Answer: A
Solution
Answer: (A) Let the distance from to be . The distance between and is , so lies at height below . Since , triangle triangle with ratio of heights . Areas scale as the square:The trapezium . Therefore - A.
- Question 8General Aptitudemcq2 marksA fair six-faced dice, with the faces labelled '1', '2', '3', '4', '5', and '6', is rolled thrice. What is the probability of rolling '6' exactly once?
- A.✓
- B.
- C.
- D.
Answer: A
Solution
Answer: (A) This is a binomial trial with , success rolling a 6, , . - A.
- Question 9General Aptitudemcq2 marksA square paper, shown in figure (I), is folded along the dotted lines as shown in the figures (II) and (III). Then a few cuts are made as shown in figure (IV). Which one of the following patterns will be obtained when the paper is unfolded? Note: The figures shown are representative.

- A.
✓ - B.

- C.

- D.

Answer: A
Solution
Answer: (A) The square is folded twice along the two diagonals, bringing all four corners together, and the cuts in figure (IV) are made on the folded quarter. When unfolding, each cut is reflected across both fold lines (the two diagonals), so every cut appears at four symmetric positions — once in each quadrant, with the pattern mirrored about both diagonals. Reconstructing the four-fold symmetric pattern from the cuts in (IV) gives the arrangement in option (A). Options (B), (C) and (D) break the required diagonal (4-fold) symmetry, so they cannot result from folding along both diagonals. - A.
- Question 10General Aptitudemcq2 marksA shop has 4 distinct flavors of ice-cream. One can purchase any number of scoops of any flavor. The order in which the scoops are purchased is inconsequential. If one wants to purchase 3 scoops of ice-cream, in how many ways can one make that purchase?
- A.4
- B.20✓
- C.24
- D.48
Answer: B
Solution
Answer: (B) 20 Choosing 3 scoops from 4 flavors with repetition allowed, order irrelevant, is a combination with repetition (stars and bars): - A.
- Question 11Computer Organization & Architecturemcq1 markSuppose a program is running on a non-pipelined single processor computer system. The computer is connected to an external device that can interrupt the processor asynchronously. The processor needs to execute the interrupt service routine (ISR) to serve this interrupt. The following steps (not necessarily in order) are taken by the processor when the interrupt arrives: (i) The processor saves the content of the program counter. (ii) The program counter is loaded with the start address of the ISR. (iii) The processor finishes the present instruction. Which ONE of the following is the CORRECT sequence of steps?
- A.(iii), (i), (ii)✓
- B.(i), (iii), (ii)
- C.(i), (ii), (iii)
- D.(iii), (ii), (i)
Answer: A
Solution
Answer: (A) (iii), (i), (ii) On an interrupt, the processor: 1. (iii) finishes the current instruction (interrupts are checked at instruction boundaries), 2. (i) saves the PC (return address) so it can resume later, 3. (ii) loads the PC with the ISR start address to begin servicing. Saving the PC must happen before overwriting it with the ISR address, so the order is (iii) → (i) → (ii). - A.
- Question 12Compiler Designmcq1 markWhich ONE of the following statements is FALSE regarding the symbol table?
- A.Symbol table is responsible for keeping track of the scope of variables.
- B.Symbol table can be implemented using a binary search tree.
- C.Symbol table is not required after the parsing phase.✓
- D.Symbol table is created during the lexical analysis phase.
Answer: C
Solution
Answer: (C) — this statement is FALSE. The symbol table is used well beyond parsing — in semantic analysis (type checking, scope resolution), intermediate code generation, optimization and final code generation. So "not required after the parsing phase" is false. The other statements are true: the symbol table tracks scope (A), can be implemented with a BST/hash table (B), and entries begin to be created as early as lexical analysis (D). - A.
- Question 13Compiler Designmcq1 markWhich ONE of the following techniques used in compiler code optimization uses live variable analysis?
- A.Run-time function call management
- B.Register assignment to variables✓
- C.Strength reduction
- D.Constant folding
Answer: B
Solution
Answer: (B) Register assignment to variables Live variable analysis computes, for each program point, which variables are live (will be used before being redefined). This is exactly the information needed for register allocation: two variables that are never simultaneously live can share a register, and dead values need not be kept in registers. Strength reduction and constant folding are algebraic/value optimizations; run-time call management is unrelated to liveness. - A.
- Question 14Operating Systemsmcq1 markConsider a demand paging memory management system with 32-bit logical address, 20-bit physical address, and page size of 2048 bytes. Assuming that the memory is byte addressable, what is the maximum number of entries in the page table?
- A.✓
- B.
- C.
- D.
Answer: A
Solution
Answer: (A) Page size bytes, so the page offset is bits. With a -bit logical address, the page-number field is bits. The number of page-table entries equals the number of pages in the logical address space:(The physical address width determines frame-number size, not the number of page-table entries.) - A.
- Question 15Databasesmcq1 markA schedule of three database transactions , , and is shown. and denote read and write of data item by transaction , . The transaction aborts at the end. Which other transaction(s) will be required to be rolled back?
- A.Only
- B.Only
- C.Both and✓
- D.Neither nor
Answer: C
Solution
Answer: (C) Both and writes with and later aborts, so every transaction that read the uncommitted value of performs a dirty read and must be rolled back (cascading rollback). - reads after → read dirty data → roll back . - also reads (whose last writer is , since never wrote ) → read dirty data → roll back . Hence both and must be rolled back. - A.
- Question 16Computer Networksmcq1 markIdentify the ONE CORRECT matching between the OSI layers and their corresponding functionalities as shown.
OSI Layer | Functionality --------------------+---------------------------- (a) Network layer | (I) Packet routing (b) Transport layer | (II) Framing and error handling (c) Datalink layer | (III) Host to host communication- A.(a)-(I), (b)-(II), (c)-(III)
- B.(a)-(I), (b)-(III), (c)-(II)✓
- C.(a)-(II), (b)-(I), (c)-(III)
- D.(a)-(III), (b)-(II), (c)-(I)
Answer: B
Solution
Answer: (B) (a)-(I), (b)-(III), (c)-(II) - Network layer → packet routing (logical addressing, path selection): (I). - Transport layer → end-to-end / host-to-host communication (e.g. TCP, UDP): (III). - Data-link layer → framing and error handling (frames, CRC): (II). - A.
- Question 17Discrete Mathematicsmcq1 markis a function from to , is a function from to , and their composition defined as is a mapping from to . If and are onto (surjective) functions, which ONE of the following is TRUE about the function ?
- A.must be an onto (surjective) function.
- B.must be a one-to-one (injective) function.
- C.must be a bijective function, that is, both one-to-one and onto.
- D.is not required to be a one-to-one or onto function.✓
Answer: D
Solution
Answer: (D) is not required to be one-to-one or onto. If is onto then must be onto — but nothing forces to be onto or injective. Counterexample: , , . Let (not onto , trivially injective but need not be) and . Then is onto and is onto , yet is not onto . One can likewise make non-injective. So need not be injective or surjective. - A.
- Question 18Algorithmsmcq1 markLet be any undirected graph with positive edge weights, and be a minimum spanning tree of . For any two vertices, and , let and be the shortest distances between and in and , respectively. Which ONE of the options is CORRECT for all possible and ?
- A.
- B.✓
- C.
- D.
Answer: B
Solution
Answer: (B) is a subgraph of (it uses only edges of ). Any – path in is also a path in , so the shortest path in can only be shorter or equal:Equality can occur (e.g. a tree edge), and strict inequality is common (a direct non-tree edge in may be shorter), so (A), (C), (D) fail in general. - A.
- Question 19Theory of Computationmcq1 markConsider the following context-free grammar , where are the variables (non-terminals), and are the terminal symbols, is the start variable, and the rules of are:
Which ONE of the languages is accepted by ?S -> aaB | Abb A -> a | aA B -> b | bB- A.✓
- B.
- C.
- D.
Answer: A
Solution
Answer: (A) generates (one or more 's); generates . - with . - with . Their union is exactly option (A). - A.
- Question 20Algorithmsmcq1 markConsider the following recurrence relation:Which ONE of the following options is CORRECT?
- A.✓
- B.
- C.
- D.
Answer: A
Solution
Answer: (A) Divide by . Let :With , . Therefore - A.
- Question 21Databasesmsq1 markConsider the shown tree with 5 nodes, in which a node can store at most 3 key values. The value 23 is now inserted in the tree. Which of the following option(s) is/are CORRECT?

- A.None of the nodes will split.
- B.At least one node will split and redistribute.✓
- C.The total number of nodes will remain same.
- D.The height of the tree will increase.✓
Answer: B, D
Solution
Answer: (B) and (D) The rightmost leaf is already full (max 3 keys). Inserting 23 gives → overflow, so this leaf splits and a separator key is copied up to the root. The root is (also full). Adding the copied-up key makes it → the root overflows and splits too, creating a new root. A new root means the height increases. So (B) a split/redistribution happens, and (D) the height increases. (A) is false, and (C) is false because the node count rises from 5 to 7. - A.
- Question 22Computer Networksmsq1 markConsider the 3-way handshaking protocol for TCP connection establishment. Let the three packets exchanged during the connection establishment be denoted as P1, P2, and P3, in order. Which of the following option(s) is/are TRUE with respect to TCP header flags that are set in the packets?
- A.P3: SYN = 1, ACK = 1
- B.P2: SYN = 1, ACK = 1✓
- C.P2: SYN = 0, ACK = 1
- D.P1: SYN = 1✓
Answer: B, D
Solution
Answer: (B) and (D) TCP's three-way handshake: - P1 (client → server): SYN (request). → (D) True. - P2 (server → client): SYN , ACK (SYN-ACK). → (B) True, so (C) is False. - P3 (client → server): SYN , ACK (pure ACK). → (A) is False. - A.
- Question 23Engineering Mathematicsmsq1 markConsider the given system of linear equations for variables and , where is a real-valued constant. Which of the following option(s) is/are CORRECT?
- A.There is exactly one value of for which the system has no solution.✓
- B.There exist an infinite number of values of for which the system has no solution.
- C.There exists exactly one value of for which the system has exactly one solution.
- D.There exists exactly one value of for which the system has an infinite number of solutions.✓
Answer: A, D
Solution
Answer: (A) and (D) The coefficient determinant is , which is zero only at . - For : unique solution (so (C) is false — there are infinitely many such , not one). - : equations become and — inconsistent → no solution. This is the only such → (A) True, and (B) False. - : equations become and , i.e. the same line → infinitely many solutions, the only such → (D) True. - A.
- Question 24Digital Logicmsq1 markLet be a 3-variable Boolean function that produces output '1' when at least two of the input variables are '1' (the majority function). Which of the following statement(s) is/are CORRECT, where are Boolean variables?
- A.
- B.✓
- C.
- D.✓
Answer: B, D
Solution
Answer: (B) and (D) is the majority function . - (B) Let . If then and . If then and . In all cases . True. - (D) , so RHS with . If it equals ; if then . So RHS LHS. True. - (A) Majority is not associative in this nested sense; a counterexample (e.g. ) makes the two sides differ. False. - (C) and , so RHS , which does not equal the LHS in general. False. - A.
- Question 25Digital Logicmsq1 markThe number can be represented as in 4-bit 2's complement representation. Which of the following is/are CORRECT 2's complement representation(s) of ?
- A.1000 1010 in 8-bits
- B.1111 1010 in 8-bits✓
- C.1000 0000 0000 1010 in 16-bits
- D.1111 1111 1111 1010 in 16-bits✓
Answer: B, D
Solution
Answer: (B) and (D) To widen a 2's complement number, perform sign extension: copy the sign bit (here , since the number is negative) into all the new high-order bits. → - 8-bit: → (B). - 16-bit: → (D). Options (A) and (C) pad with s (or a stray ), which changes the value and is incorrect. - A.
- Question 26Programming & Data Structuresmsq1 markWhich of the following statement(s) is/are TRUE for any binary search tree (BST) having distinct integers?
- A.The maximum length of a path from the root node to any other node is .✓
- B.An inorder traversal will always produce a sorted sequence of elements.✓
- C.Finding an element takes time in the worst case.
- D.Every BST is also a Min-Heap.
Answer: A, B
Solution
Answer: (A) and (B) - (A) A completely skewed BST (each node has one child) forms a chain of nodes → longest root-to-node path has edges. True (this is the maximum). - (B) Inorder traversal of a BST always visits keys in increasing order. True. - (C) Search is ; in the worst case (skewed tree) , so worst case is , not . False. - (D) A BST orders left root right; a Min-Heap requires parent children with no left/right ordering. A BST is generally not a min-heap. False. - A.
- Question 27Computer Organization & Architecturemsq1 markA partial data path of a processor is given in the figure, where RA, RB, and RZ are 32-bit registers. Which option(s) is/are CORRECT related to arithmetic operations using the data path as shown?

- A.The data path can implement arithmetic operations involving two registers.✓
- B.The data path can implement arithmetic operations involving one register and one immediate value.✓
- C.The data path can implement arithmetic operations involving two immediate values.✓
- D.The data path can only implement arithmetic operations involving one register and one immediate value.
Answer: A, B, C
Solution
Answer: (A), (B) and (C) Each ALU operand is driven by its own multiplexer: - Mux_A selects between register RA and a 32-bit immediate. - Mux_B selects between register RB and a 32-bit immediate. Because the two muxes are independent, the ALU inputs can be any combination: - (A) RA and RB → two registers. ✓ - (B) one register + one immediate (e.g. RA and immediate). ✓ - (C) immediate on Mux_A and immediate on Mux_B → two immediates. ✓ - (D) says it can only do register+immediate, which is false since (A) and (C) are also possible. - A.
- Question 28Theory of Computationmsq1 markA regular language is accepted by a non-deterministic finite automaton (NFA) with states. Which of the following statement(s) is/are FALSE?
- A.may have an accepting NFA with states.
- B.may have an accepting DFA with states.
- C.There exists a DFA with states that accepts .
- D.Every DFA that accepts has states.✓
Answer: D
Solution
Answer: (D) — this is the FALSE statement. By the subset construction, an -state NFA has an equivalent DFA with at most states. So (C) is true, and (D) ("every DFA has more than states") is false — in fact the minimal DFA often has far fewer. (A) and (B) are true possibilities: the given NFA/DFA need not be minimal, so may have an accepting NFA or DFA with fewer than states. - A.
- Question 29Operating Systemsnat1 markSuppose in a multiprogramming environment, the following C program segment is executed. A process goes into I/O queue whenever an I/O related operation is performed. Assume that there will always be a context switch whenever a process requests for an I/O, and also whenever the process returns from an I/O. The number of times the process will enter the ready queue during its lifetime (not counting the time the process enters the ready queue when it is run initially) is _______. (Answer in integer)
int main() { int x=0,i=0; scanf("%d",&x); for(i=0; i<20; i++) { x = x+20; printf("%d\n",x); } return 0; }Answer: 21
Solution
Answer: 21 Each I/O operation causes the process to move to the I/O queue; when the I/O completes, the process returns to the ready queue. So the process re-enters the ready queue once per I/O operation (the initial entry is excluded by the question). I/O operations here: -scanf→ 1 I/O. -printfinside the loop, executed 20 times → 20 I/O. Total re-entries . - Question 30Discrete Mathematicsnat1 markLet be the set of all ternary strings defined over the alphabet . Consider all strings in that contain at least one occurrence of two consecutive symbols, that is, "aa", "bb" or "cc". The number of such strings of length 5 that are possible is _______. (Answer in integer)
Answer: 195
Solution
Answer: 195 Use complementary counting. - Total strings of length 5: . - Strings with no two consecutive equal symbols: the first symbol has choices, each later symbol has choices (anything except the previous one): . Strings with at least one "aa"/"bb"/"cc" - Question 31Engineering Mathematicsnat1 markConsider the given function :If the function is differentiable everywhere, the value of must be ________. (rounded off to one decimal place)
Answer: -2.1 to -1.9
Solution
Answer: For differentiability at , both the value and the derivative must match. Derivative of the right piece: ; at it is . The left piece has slope , so . Continuity at : left value ; right value . Setting them equal: - Question 32Engineering Mathematicsnat1 markA box contains 5 coins: 4 regular coins and 1 fake coin. When a regular coin is tossed, and for a fake coin . You pick a coin at random and toss it twice, and get two heads. The probability that the coin you have chosen is the fake coin is _______. (rounded off to two decimal places)
Answer: 0.49 to 0.51
Solution
Answer: Let = fake, = regular. , .By total probability:By Bayes' theorem: - Question 33Algorithmsnat1 markThe pseudocode of a function fun() is given below:
Let be an array storing 30 distinct integers in descending order. The number of swap operations that will be performed, if fun() is called with , is __________. (Answer in integer)fun(int A[0..n-1]){ for i=0 to n-2 for j=0 to n-i-2 if (A[j] > A[j+1]) then swap A[j] and A[j+1] }Answer: 435
Solution
Answer: 435funis bubble sort. For an array sorted in strictly descending order (the worst case), every compared adjacent pair is out of order, so each comparison causes a swap. The number of comparisons (and hence swaps) is - Question 34Programming & Data Structuresnat1 markConsider the C program:
The output of the given C program is __________. (Answer in integer)#include <stdio.h> void foo(int *p, int x){ *p = x; } int main(){ int *z; int a = 20, b = 25; z = &a; foo(z, b); printf("%d", a); return 0; }Answer: 25
Solution
Answer: 25zpoints toa. The callfoo(z, b)passes this pointer and the valueb = 25. Insidefoo,*p = xwrites25through the pointer, i.e. intoa. Soabecomes25, andprintf("%d", a)prints . - Question 35Programming & Data Structuresnat1 markThe height of any rooted tree is defined as the maximum number of edges in the path from the root node to any leaf node. Suppose a Min-Heap stores 32 keys. The height of is _____________. (Answer in integer)
Answer: 5
Solution
Answer: 5 A heap is a complete binary tree, whose height (in edges) for nodes is .(Levels – hold nodes; the 32nd node sits on level , so the longest root-to-leaf path has 5 edges.) - Question 36Computer Organization & Architecturemcq2 marksConsider a memory system with 1M bytes of main memory and 16K bytes of cache memory. Assume that the processor generates 20-bit memory address, and the cache block size is 16 bytes. If the cache uses direct mapping, how many bits will be required to store all the tag values? [Assume memory is byte addressable, , .]
- A.✓
- B.
- C.
- D.
Answer: A
Solution
Answer: (A) Address bits. Block size → offset bits. Number of cache lines → index (line) bits. Tag bits per line. Total tag storage bits. - A.
- Question 37Computer Organization & Architecturemcq2 marksA processor has 64 general-purpose registers and 50 distinct instruction types. An instruction is encoded in 32-bits. What is the maximum number of bits that can be used to store the immediate operand for the given instruction?
ADD R1, #25 // R1 = R1 + 25- A.16
- B.20✓
- C.22
- D.24
Answer: B
Solution
Answer: (B) 20 Field sizes: - Opcode: 50 instruction types need bits. - Register: 64 registers need bits (one register operand, R1). The instructionADD R1, #immuses one opcode + one register + the immediate. In 32 bits: - A.
- Question 38Operating Systemsmcq2 marksA computer has two processors, and . Four processes with CPU bursts of 20, 16, 25, and 10 ms, respectively, arrive at the same time and are the only processes in the system. The scheduler uses non-preemptive priority scheduling, with priorities: - : (so highest, lowest). - : (so highest, lowest). A process is scheduled on a free processor if no higher-priority process is waiting. A process can go to any free processor without violating priority rules. Ignore context-switch time. What is the average waiting time (ms)?
- A.9.00✓
- B.8.75
- C.6.50
- D.7.50
Answer: A
Solution
Answer: (A) 9.00 At both processors are free: - picks its highest-priority process (burst 20) → runs . - picks its highest-priority process (burst 16) → runs . At , frees. Remaining ; by 's order , so (burst 25) → runs . At , frees. Only left → (burst 10) → runs . Waiting times (start arrival): . - A.
- Question 39Databasesmcq2 marksConsider two relations describing and : - - Which ONE of the following tuple relational calculus queries returns the name of the players who play for the team having as 'MI'?
- A.✓
- B.
- C.
- D.
Answer: A
Solution
Answer: (A) We want player names, so must range over (eliminating (B),(D)). We must link the player's team to a tuple named 'MI', which requires the join condition and . Option (C) drops the join , so it would return every player's name as long as some 'MI' team exists — wrong. Only (A) correctly joins the player to the 'MI' team. - A.
- Question 40Computer Networksmcq2 marksA packet with destination IP address 145.36.109.70 arrives at a router whose routing table is shown. Which interface will the packet be forwarded to?
Subnet Address | Subnet Mask (CIDR) | Interface ---------------+--------------------+---------- 145.36.0.0 | /16 | E1 145.36.128.0 | /17 | E2 145.36.64.0 | /18 | E3 145.36.255.0 | /24 | E4 Default | -- | E5- A.E3✓
- B.E1
- C.E2
- D.E5
Answer: A
Solution
Answer: (A) E3 Routers use longest-prefix match. The third octet is . - /16 (): matches. - /17 (): needs third-octet top bit (); → no match. - /18 (): needs third-octet top two bits (range –); is in → match. - /24 (): third octet must be → no. The longest matching prefix is → interface E3. - A.
- Question 41Engineering Mathematicsmcq2 marksLet be the matrix . What are the eigenvalues of the matrix ?
- A.
- B.
- C.
- D.✓
Answer: D
Solution
Answer: (D) Eigenvalues of : . Eigenvalues of are : - A.
- Question 42Digital Logicmcq2 marksConsider the four-variable Boolean function in sum-of-products formwhere is read as a 4-bit binary number ( MSB). There are no don't-care terms. Which ONE of the following is the CORRECT minimized Boolean expression for ?
- A.✓
- B.
- C.
- D.
Answer: A
Solution
Answer: (A) Plot minterms on a K-map: - share → group . - share → group . - Minterm is covered only together with : they share → group . Covering all seven minterms minimally giveswhich is option (A). The other options miss minterm or include extra minterms. - A.
- Question 43Algorithmsmcq2 marksLet be an undirected, unweighted graph with 100 vertices. Let denote the number of edges in a shortest path between and . Suppose (the diameter). Let be any breadth-first-search tree of . Which ONE of the options is CORRECT for every such graph ?
- A.The height of is exactly 15.
- B.The height of is exactly 30.
- C.The height of is at least 15.✓
- D.The height of is at least 30.
Answer: C
Solution
Answer: (C) The height of is at least 15. A BFS tree rooted at has height equal to the eccentricity of (the maximum distance from to any vertex). For any root and the diametral pair with :So , i.e. the BFS-tree height is at least 15 for every root. It can be exactly 15 (root at the center) or as large as 30 (root at a diametral endpoint), so "exactly 15/30" and "at least 30" are not guaranteed. - A.
- Question 44Theory of Computationmcq2 marksConsider the following two languages over the alphabet :Which ONE of the following statements is CORRECT?
- A.Both and are regular languages.
- B.is a regular language but is not a regular language.
- C.is not a regular language but is a regular language.✓
- D.Neither nor is a regular language.
Answer: C
Solution
Answer: (C) is not regular but is regular. is regular. Since consists only of 's, we can always take (a single ) and let be the middle. So is exactly the set of strings that start with , end with , and have length — described by the regular expression . is not regular. Here may be any non-empty string, and the same must appear as both a prefix and a suffix. When the first and last symbols differ (e.g. ), a single-symbol border no longer works, and the automaton would have to match an arbitrarily long prefix against the suffix — which a finite automaton cannot do (provable by the pumping lemma). Hence is not regular. - A.
- Question 45Theory of Computationmcq2 marksConsider the following two languages over , where are natural numbers:Which ONE of the following statements is CORRECT?
- A.Both and are context-free languages.
- B.is a context-free language but is not a context-free language.
- C.is not a context-free language but is a context-free language.✓
- D.Neither nor are context-free languages.
Answer: C
Solution
Answer: (C) is not context-free but is context-free. is context-free. We need . A PDA (or grammar) pushes one symbol for each and each , then pops one for each :
This generates . is not context-free. It requires and , i.e. two independent comparisons tied to . A single stack can match 's with 's, but after that the count is lost and cannot be compared again with the 's. By the pumping lemma for CFLs (pump ), fails to be context-free.S -> a S c | B B -> b B c | b c - A.
- Question 46Compiler Designmsq2 marksWhich of the following statement(s) is/are TRUE while computing First and Follow during top-down parsing by a compiler?
- A.For a production , will be added to .✓
- B.If there is any input right end marker, it will be added to , where is the start symbol.
- C.For a production , will be added to .
- D.If there is any input right end marker, it will be added to , where is the start symbol.✓
Answer: A, D
Solution
Answer: (A) and (D) - (A) By definition, if then . True. - (D) The end-of-input marker is always placed in of the start symbol . True. - (B) The end-of-input marker goes into , never into any set. False. - (C) is never added to any set; sets contain only terminals and the end-of-input marker. False. - A.
- Question 47Databasesmsq2 marksConsider a relational schema with functional dependencies . The relation is decomposed into and . Which of the following statement(s) is/are TRUE?
- A.The relation is NOT in BCNF.
- B.The relations and are in BCNF.✓
- C.The decomposition constitutes a lossless join.✓
- D.The relation is NOT in 3NF.
Answer: B, C
Solution
Answer: (B) and (C) The only determinant is , and is the (candidate) key of . Every FD has a superkey on its left, so is in BCNF (hence also in 3NF). Therefore (A) and (D) are false. - (B) Each decomposed relation has as its key with FDs and respectively — both in BCNF. True. - (C) The common attribute is a key of both and , so the decomposition is lossless. True. - A.
- Question 48Discrete Mathematicsmsq2 marksWhich of the following predicate logic formulae is/are CORRECT representation(s) of: "Everyone has exactly one mother"? Predicates: means " is the mother of "; means " and are not equal".
- A.
- B.✓
- C.
- D.✓
Answer: B, D
Solution
Answer: (B) and (D) "Exactly one mother" = there exists a mother, and no other individual is also a mother. - (B) a mother , and every is not a mother → existence + uniqueness. True. - (D) a mother , and there is no that is a mother → same meaning. True. - (A) merely says some is a mother and some is not a mother — does not enforce uniqueness. False. - (C) can be taken equal to (since means ), making it trivially true; it enforces neither existence nor uniqueness. False. - A.
- Question 49Discrete Mathematicsmsq2 marksis the set of non-negative integers. Let be the set of functions from to itself. For , define for every . Which of the following is/are CORRECT about the structure ?
- A.is an Abelian group.
- B.is an Abelian monoid.✓
- C.is a non-Abelian group.
- D.is a non-Abelian monoid.
Answer: B
Solution
Answer: (B) an Abelian monoid The operation is pointwise addition of functions. - Closure & associativity: inherited from integer addition. ✓ - Identity: the zero function satisfies , and . ✓ → it is a monoid. - Commutative: → Abelian. ✓ - Inverses: an inverse of would need , but negative values are not in (non-negative integers). So only has an inverse → not a group. Hence is an Abelian monoid, but not a group. - A.
- Question 50Theory of Computationmsq2 marksConsider the deterministic finite automaton (DFA) shown, over . Identify which of the following language(s) is/are accepted by the given DFA.

- A.The set of all strings containing an even number of 's.
- B.The set of all strings containing the pattern .
- C.The set of all strings ending with the pattern .✓
- D.The set of all strings not containing the pattern .
Answer: C
Solution
Answer: (C) The set of all strings ending with the pattern . The DFA is the standard 4-state minimal automaton that tracks the longest suffix matching a prefix of : (nothing) () () (, accepting); with , , , and the self-loops shown. The only accepting state is reached exactly after reading a suffix . If another follows, leaves the accepting state — so e.g. "" contains but is rejected, ruling out (B). The DFA accepts precisely strings ending in . (A) and (D) are easily refuted by the same automaton. - A.
- Question 51Operating Systemsnat2 marksA disk of size 512M bytes is divided into blocks of 64K bytes. A file is stored using linked allocation. Each data block reserves 4 bytes to store the pointer to the next block; the last block's link is a NULL pointer (also 4 bytes). A file of 1M bytes is stored. Assume , . The amount of space in bytes wasted due to internal fragmentation is ______. (Answer in integer)
Answer: 65468
Solution
Answer: 65468 Each -byte block reserves bytes for the pointer, leaving bytes of data per block. File size bytes. Blocks needed blocks. - First 16 blocks hold bytes. - Remaining file data bytes, placed in the 17th block. Internal fragmentation is the unused data area of the last block: - Question 52Compiler Designnat2 marksRefer to the given 3-address code sequence, split into basic blocks. The number of basic blocks is ________. (Answer in integer)
1001: i = 1 1002: j = 1 1003: t1 = 10*i 1004: t2 = t1+j 1005: t3 = 8*t2 1006: t4 = t3-88 1007: a[t4] = 0.0 1008: j = j+1 1009: if j <= 10 goto 1003 1010: i = i+1 1011: if i <= 10 goto 1002 1012: i = 1 1013: t5 = i-1 1014: t6 = 88*t5 1015: a[t6] = 1.0 1016: i = i+1 1017: if i <= 10 goto 1013Answer: 6
Solution
Answer: 6 Leaders are: the first statement, any jump target, and any statement following a conditional/unconditional jump. - First statement: 1001. - Jump targets: 1003, 1002, 1013. - Statements right after a jump: 1010 (after 1009), 1012 (after 1011). Leaders . Each leader begins a basic block:
That is 6 basic blocks.B1: 1001 B2: 1002 B3: 1003–1009 B4: 1010–1011 B5: 1012 B6: 1013–1017 - Question 53Computer Organization & Architecturenat2 marksA computer has a two-level cache (L1, L2) and main memory. On an access the processor checks L1, then L2, then main memory (data is always found there). From the figure: L1 hit rate , access time ns; L2 hit rate , access time (including L1 miss penalty) ns; main memory access time (including L1 and L2 miss penalty) ns. The average memory access time (ns) is ________. (rounded off to two decimal places)
Answer: 11.83 to 11.87
Solution
Answer: 11.85 Interpret each stated time as the total time to obtain data at that level (penalties already included): - Question 54Operating Systemsnat2 marksIn optimal page replacement, all future references are known. A modification: the OS correctly predicts only the next 4 page references (including the current one) at the time of allocating a frame. A process accesses pages in order:With three frames initially empty, the number of page faults during execution is ________. (Answer in integer)
Answer: 6
Solution
Answer: 6 Three frames, evict the page whose next use within the 4-reference window is farthest (or not used in the window):Total page faults .ref | frames after | fault? (eviction) 1 | 1 | fault 3 | 1 3 | fault 2 | 1 3 2 | fault 4 | 3 2 4 | fault (window 4,2,3,1: 1 used farthest -> evict 1) 2 | 3 2 4 | hit 3 | 3 2 4 | hit 1 | 2 4 1 | fault (window 1,2,4,3: 3 farthest -> evict 3) 2 | 2 4 1 | hit 4 | 2 4 1 | hit 3 | 4 1 3 | fault (window 3,1,4: 2 not used -> evict 2) 1 | 4 1 3 | hit 4 | 4 1 3 | hit - Question 55Databasesnat2 marksConsider the database tables (instances shown) and the SQL query. The value returned by the query is ______. (Answer in integer)
player coach team members pid pname age cid cname tid tname city cid pid tid 1 Jasprit 31 101 Ricky 10 MI Mumbai 102 1 10 2 Atharva 24 102 Mark 20 DC Delhi 101 2 30 3 Ishan 26 103 Trevor 30 PK Mohali 103 3 10 4 Axar 30 4 20SELECT MIN(P.age) FROM player P WHERE P.pid IN ( SELECT M.pid FROM team T, coach C, members M WHERE C.cname = 'Mark' AND T.cid = C.cid AND M.tid = T.tid )Answer: 26
Solution
Answer: 26 - Coach 'Mark' has . - Team with is MI (). - Members of team : (Jasprit) and (Ishan). - Their ages: Jasprit , Ishan . - Question 56Computer Networksnat2 marksA 5-bit message is transmitted through a noisy channel. The probability that a bit gets flipped is 0.01, independently for each bit. The probability that the message is delivered error-free is ______. (rounded off to three decimal places)
Answer: 0.949 to 0.952
Solution
Answer: 0.951 Error-free means all 5 bits are received correctly. Each bit is correct with probability , independently: - Question 57Computer Networksnat2 marksA message of size 15000 bytes is transmitted from source to destination using IPv4 via two routers: Source → Router-1 (MTU bytes) → Router-2 (MTU bytes) → Destination. Each MTU includes the 20-byte IP header. The number of fragments delivered to the destination is ________. (Answer in integer)
Answer: 7
Solution
Answer: 7 IP header bytes; fragment data must be a multiple of 8. At Router-1 (MTU 5000): max data per fragment round down to (multiple of 8). data bytes fragments of → 4 fragments. At Router-2 (MTU 3000): max data per fragment . - Each -byte fragment is refragmented into → 2 fragments. Three of them give . - The -byte fragment fits as is → 1 fragment. Total delivered fragments. - Question 58Engineering Mathematicsnat2 marksConsider a probability distribution with densityThe probability that lies between 2 and 3, i.e. , is __________. (rounded off to three decimal places)
Answer: 0.3 to 0.302
Solution
Answer: 0.302 Normalize to find :Then - Question 59Digital Logicnat2 marksConsider a finite state machine (FSM) with one input and one output , given by the state transition table. The minimum number of states required to realize this FSM is ________. (Answer in integer)
Present | Next (X=0) | Next (X=1) | f(X=0) | f(X=1) --------+------------+------------+--------+------- A | F | B | 0 | 0 B | D | C | 0 | 0 C | F | E | 0 | 0 D | G | A | 1 | 0 E | D | C | 0 | 0 F | F | B | 1 | 1 G | G | H | 0 | 1 H | G | A | 1 | 0Answer: 5
Solution
Answer: 5 Minimize by partition refinement (group states that are indistinguishable). Initial grouping by output : (0,0), (1,0), (1,1), (0,1). Refine by where their transitions lead: go to while go to → split into and . stay together (both: , ). Final partition: — and it is stable. So the minimized machine has states. - Question 60Digital Logicnat2 marksConsider the given sequential circuit designed using D flip-flops. The circuit is initialized with some value (initial state). The number of distinct states the circuit will go through before returning back to the initial state is _________. (Answer in integer)

Answer: 7 to 8
Solution
Answer: 8 The outputs are connected as a shift register , and the complemented last output feeds back to the first: . This is a 4-bit Johnson (twisted-ring) counter. Starting from the state sequence is:
which visits distinct states ( for flip-flops) before repeating.0000 -> 1000 -> 1100 -> 1110 -> 1111 -> 0111 -> 0011 -> 0001 -> (0000) - Question 61Programming & Data Structuresnat2 marksConsider the C program:
The value printed by the given C program is _______. (Answer in integer)#include <stdio.h> int foo(int S[], int size){ if(size == 0) return 0; if(size == 1) return 1; if(S[0] != S[1]) return 1 + foo(S+1, size-1); return foo(S+1, size-1); } int main(){ int A[] = {0,1,2,2,2,0,0,1,1}; printf("%d", foo(A,9)); return 0; }Answer: 5
Solution
Answer: 5fooscans adjacent pairs, adding 1 wheneverS[0] != S[1], and adds a final 1 at thesize==1base case. This counts the number of maximal runs of equal consecutive elements (i.e. ). For the runs are:There are adjacent-difference positions, plus the base : . - Question 62Programming & Data Structuresnat2 marksTwo linked lists are given (contents shown). L1 has 9 nodes, L2 has 7 nodes:
The code below modifies L1. The number of nodes in L1 after execution is ________. (Answer in integer)L1: 1 -> 7 -> 12 -> 3 -> 9 -> 5 -> 11 -> 15 -> 8 -> NULL L2: 1 -> 11 -> 6 -> 9 -> 15 -> 12 -> 4 -> NULLint find (int query, LIST *list) { while (list != NULL){ if(list->data == query) return 1; list = list->next; } return 0; } int main () { ptr1 = L1; ptr2 = L2; while (ptr1->next != NULL){ query = ptr1->next->data; if (find (query, L2)) ptr1->next = ptr1->next->next; // unlink else ptr1 = ptr1->next; } return 0; }Answer: 5
Solution
Answer: 5 The loop walks L1 and deletes every node (after the head) whose value also appears in L2. The head node (value 1) is never examined for deletion (the loop looks atptr1->next). L2 as a set . Checking L1's non-head nodes:
Removed: → 4 nodes deleted. Remaining L1 .7 -> keep 12 -> remove 3 -> keep 9 -> remove 5 -> keep 11 -> remove 15 -> remove 8 -> keep - Question 63Programming & Data Structuresnat2 marksConsider the C program:
The value printed by the given C program is _______. (Answer in integer)#include <stdio.h> int gate (int n) { int d, t, newnum, turn; newnum = turn = 0; t = 1; while (n >= t) t *= 10; t /= 10; while (t > 0) { d = n/t; n = n%t; t /= 10; if (turn) newnum = 10*newnum + d; turn = (turn + 1) % 2; } return newnum; } int main () { printf ("%d", gate(14362)); return 0; }Answer: 46
Solution
Answer: 46 The function reads digits of from most significant to least, and keeps a digit only on alternate turns, starting by skipping the first ( begins at 0, so digit 1 is skipped, digit 2 kept, ...). Digits of : .
So it keeps the 2nd and 4th digits → .turn=0: d=1 skipped turn->1 turn=1: d=4 newnum = 4 turn->0 turn=0: d=3 skipped turn->1 turn=1: d=6 newnum = 46 turn->0 turn=0: d=2 skipped - Question 64Algorithmsnat2 marksThe maximum value of such that the edge between the nodes B and C is included in every minimum spanning tree of the given graph is _________. (answer in integer)

Answer: 5
Solution
Answer: 5 Edge weights: , and the diagonals and are and . An edge is in every MST iff, in every cycle containing , some other edge is strictly heavier than (cut/cycle property). The binding cycle through is , whose other edges are with maximum weight . For to be forced into every MST we need , i.e. . Check : after adding the two light diagonals ( and ) the two components and must be joined by the cheapest crossing edge; the crossing edges are , and is the unique minimum → is in every MST. At , ties with and is no longer forced. Hence . - Question 65Programming & Data Structuresnat2 marksIn a double hashing scheme, and are the auxiliary hash functions. The table size . The -th probe uses . The keys are inserted in order: . The slot at which key 24 gets stored is ___________. (Answer in integer)
Answer: 10 to 11
Solution
Answer: 10 Insert each key (slots –):
For key 24: (occupied by 79), . - (occupied by 50). - (empty) → slot 10. Key 24 is stored at slot .63: h1 = 63 mod 11 = 8 -> slot 8 50: h1 = 50 mod 11 = 6 -> slot 6 25: h1 = 25 mod 11 = 3 -> slot 3 79: h1 = 79 mod 11 = 2 -> slot 2 67: h1 = 67 mod 11 = 1 -> slot 1
Practice the full paper with a timer
Attempt GATE CS 2025 Set 1 in the exact GATE interface and get a detailed score and topic-wise analysis — free.
Create free account →