Organised by IIT Roorkee

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

63 questions with the official answer key and a worked solution for each. Try a question before opening its answer.

Practise this paper with instant checking
Q1MCQ1 mark · -1/3· Easy

Ravi 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.

  1. (A)a; a; an
  2. (B)the; an; a
  3. (C)a; an; a
  4. (D)an; an; a
Answer: A - show solution

Articles follow the sound, not the spelling. "younger" starts with a consonant sound, so "a younger brother" (first mention, not a specific one). "university" starts with the sound "yoo", a consonant sound, so "a university". "honorable" has a silent h and starts with a vowel sound, so "an honorable man". Sequence: a; a; an. Answer: (A).

Concept: Tests choice of a/an by initial sound. The trap is choosing "an university" because u is a vowel letter, or "a honorable" because h is a consonant letter. Pronunciation decides.

Q2MCQ1 mark · -1/3· Easy

The 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.

  1. (A)visionary
  2. (B)shortsighted
  3. (C)progressive
  4. (D)innovative
Answer: B - show solution

"Myopic" literally means near-sighted and figuratively means lacking foresight. The sentence confirms this: the decision gave up long-term stability for short-term gains. Visionary, progressive and innovative are all positive and mean nearly the opposite. The only synonym is shortsighted. Answer: (B).

Concept: Vocabulary in context. The context clue "sacrificed long-term stability" points to lack of foresight; the distractors are positive words that contradict the sentence's critical tone.

Q3MCQ1 mark · -1/3· Easy

The average marks obtained by a class in an examination were calculated as 30.8. However, while checking the marks entered, the teacher found that the marks of one student were entered incorrectly as 24 instead of 42. After correcting the marks, the average becomes 31.4. How many students does the class have?

  1. (A)25
  2. (B)28
  3. (C)30
  4. (D)32
Answer: C - show solution

Let n be the number of students. Correcting the entry raises the total by 42 - 24 = 18. The average rises by 31.4 - 30.8 = 0.6. So 0.6 n = 18, giving n = 30. Answer: (C).

Concept: Change in total = change in average x count. The trap is using 24 + 42 or one of the averages directly instead of the difference of the corrected and wrong marks.

Q4MCQ1 mark · -1/3· Easy

Consider 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?

  1. (A)Both (1) and (2) are true.
  2. (B)Both (1) and (3) are true.
  3. (C)Only (3) is true.
  4. (D)Only (4) is true.
Answer: A - show solution

R is Q's mother and S is Q's daughter, so R is S's grandmother: (1) true. P is Q's brother and S, T are Q's daughters (T is S's sister), so P is their uncle: (2) true. R's children include P (a son) and Q, whose gender is not given, so "only one son" cannot be concluded: (3) not established. Q has at least two daughters, S and T: (4) false. Answer: (A).

Concept: Blood-relation deduction. The trap is assuming Q's gender (to accept or reject statement 3) - only statements that follow necessarily count as true.

Q5MCQ1 mark · -1/3· Easy

According to the map shown in the figure, which one of the following statements is correct? Note: The figure shown is representative. Map (north is up): 1st Main Road runs north-south and 5th Cross Road runs east-west, crossing at the centre. North-west block: Library (upper), Physics Lab (below it). North-east block: Canteen (upper), Hospital (below it). South-west block: Hostels (upper), Classrooms (below it). South-east block: Chemistry Lab.

  1. (A)The library is located to the northwest of the canteen.
  2. (B)The hospital is located to the east of the chemistry lab.
  3. (C)The chemistry lab is to the southeast of physics lab.
  4. (D)The classrooms and canteen are next to each other.
Answer: C - show solution

Library and Canteen are in the same top row, Library on the west side, so the library is due west of the canteen, not northwest: (A) wrong. The hospital is north of the chemistry lab (same east side, across the cross road): (B) wrong. Physics Lab is in the north-west block and Chemistry Lab in the south-east block, so the chemistry lab is south-east of the physics lab: (C) correct. Classrooms (south-west, bottom) and Canteen (north-east, top) are diagonally opposite: (D) wrong. Answer: (C).

Concept: Reading directions from a map. The usual trap is calling a same-row neighbour "northwest" because it sits in the upper-left quadrant of the map.

Q6MCQ2 marks · -2/3· Easy

"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?

  1. (A)The author of the passage carries a mirror in his pocket to reflect upon things.
  2. (B)The author of the passage had decided to write a poem on epics.
  3. (C)The pocket-knife is described as the infant of the sword.
  4. (D)Epics are described as too inconvenient to write.
Answer: C - show solution

(A) "reflected" means thought about; no mirror is mentioned. (B) He planned a book of poems about the things in his pocket, not a poem on epics. (C) The passage says the pocket-knife is "the type of all human tools, the infant of the sword" - stated directly. (D) He says the book would be too long and the age of epics is past, not that epics are inconvenient to write. Answer: (C).

Concept: Literal comprehension. Distractors exploit a pun (reflect / mirror) and twist nearby phrases (epics, too long). Only a statement directly supported by the text is correct.

Q7MCQ2 marks · -2/3· Moderate

In 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? (Figure: triangle PQR with apex P; S lies on PQ and T lies on PR, with ST parallel to the base QR.) Note: The figure shown is representative.

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

Let the height of P above QR be h. The distance between ST and QR is h/2, so P is h/2 above ST. Triangle PST is similar to triangle PQR with ratio (h/2)/h = 1/2, so its area is (1/2)² = 1/4 of triangle PQR. The trapezium SQRT is the rest: 3/4 of PQR. Ratio = (1/4)/(3/4) = 1/3. Answer: (A).

Concept: Similar triangles: areas scale with the square of the linear ratio. The trap is answering 1/4 (PST to the whole triangle) or 1/2 (the linear ratio) instead of PST to the trapezium.

Q8MCQ2 marks · -2/3· Easy

A 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?

  1. (A)75/216
  2. (B)1/6
  3. (C)1/18
  4. (D)25/216
Answer: A - show solution

Binomial with n = 3, p = 1/6. P(exactly one 6) = C(3,1) x (1/6) x (5/6)² = 3 x 25/216 = 75/216. Answer: (A).

Concept: Binomial probability. The trap is 25/216, which is the probability for one specific position of the 6 - forgetting the factor 3 for which roll shows it.

Q10MCQ2 marks · -2/3· Moderate

A 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?

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

We choose 3 scoops from 4 flavours with repetition allowed and order ignored: combinations with repetition, C(n + r - 1, r) = C(4 + 3 - 1, 3) = C(6,3) = 20. Check by cases: all three same flavour 4, two of one and one of another 4 x 3 = 12, all different C(4,3) = 4; total 20. Answer: (B).

Concept: Stars and bars (multisets). Traps: 4³ = 64 or 4 x 3 x 2 = 24 count ordered selections; C(4,3) = 4 forbids repetition.

Q11MCQ1 mark · -1/3· Easy

Suppose 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?

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

Interrupts are recognised only at instruction boundaries, so the current instruction completes first (iii). Then the return address in the PC must be saved (i), otherwise it would be lost. Only then is the PC loaded with the ISR start address (ii). Sequence: (iii), (i), (ii). Answer: (A).

Concept: Interrupt handling order. Loading the PC before saving it destroys the return address, and saving before finishing the instruction would save a mid-instruction state.

Q12MCQ1 mark · -1/3· Easy

Which ONE of the following statements is FALSE regarding the symbol table?

  1. (A)Symbol table is responsible for keeping track of the scope of variables.
  2. (B)Symbol table can be implemented using a binary search tree.
  3. (C)Symbol table is not required after the parsing phase.
  4. (D)Symbol table is created during the lexical analysis phase.
Answer: C - show solution

The symbol table records identifiers with their scope, type and storage information (A true). It can be a hash table, list or BST (B true). Entries are created as the lexer meets identifiers (D true). After parsing, semantic analysis (type checking), intermediate code generation and code generation (storage offsets) all still consult it, so it is needed beyond parsing. Statement (C) is false. Answer: (C).

Concept: The symbol table persists through all compiler phases. The trap is thinking it is a front-end-only structure.

Q13MCQ1 mark · -1/3· Easy

Which ONE of the following techniques used in compiler code optimization uses live variable analysis?

  1. (A)Run-time function call management
  2. (B)Register assignment to variables
  3. (C)Strength reduction
  4. (D)Constant folding
Answer: B - show solution

Live variable analysis finds, at each point, the variables whose current values may still be used later. Register allocation uses this: two variables whose live ranges do not overlap can share a register, and a dead variable's register can be freed. Strength reduction and constant folding work on expressions and values, not liveness; call management is a runtime concern. Answer: (B).

Concept: Liveness drives register allocation (interference graphs) and dead-code elimination. Constant folding needs constant propagation, not liveness - a common mix-up.

Q14MCQ1 mark · -1/3· Easy

Consider 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?

  1. (A)2²¹
  2. (B)2²⁰
  3. (C)2²²
  4. (D)2²⁴
Answer: A - show solution

Page size 2048 = 2¹¹ bytes, so the offset is 11 bits. A single-level page table has one entry per logical page: 2³² / 2¹¹ = 2²¹ entries. The 20-bit physical address only affects the frame-number width (20 - 11 = 9 bits per entry), not the entry count. Answer: 2²¹ (A).

Concept: Page table entries = number of virtual pages. The trap is dividing the physical address space instead (2⁹ frames), which sizes each entry, not the table.

Q15MCQ1 mark · -1/3· Easy

A schedule of three database transactions T1, T2, and T3 is shown. Ri(A) and Wi(A) denote read and write of data item A by transaction Ti, i = 1, 2, 3. The transaction T1 aborts at the end. Which other transaction(s) will be required to be rolled back? R1(X) W1(Y) R2(X) R2(Y) R3(Y) ABORT(T1)

  1. (A)Only T2
  2. (B)Only T3
  3. (C)Both T2 and T3
  4. (D)Neither T2 nor T3
Answer: C - show solution

T1 writes Y. Then T2 reads Y and T3 reads Y, both before T1 finishes - dirty reads of T1's uncommitted value. When T1 aborts, the value both read never existed, so both must be rolled back (cascading rollback). R2(X) reads X, which T1 only read, so it is harmless. Answer: Both T2 and T3 (C).

Concept: Cascading aborts come from reading uncommitted writes. The trap is focusing on X (read by T1 and T2) - read-read sharing causes no dependency.

Q16MCQ1 mark · -1/3· Easy

Identify the ONE CORRECT matching between the OSI layers and their corresponding functionalities as shown. OSI Layers: (a) Network layer, (b) Transport layer, (c) Datalink layer Functionalities: (I) Packet routing, (II) Framing and error handling, (III) Host to host communication

  1. (A)(a)-(I), (b)-(II), (c)-(III)
  2. (B)(a)-(I), (b)-(III), (c)-(II)
  3. (C)(a)-(II), (b)-(I), (c)-(III)
  4. (D)(a)-(III), (b)-(II), (c)-(I)
Answer: B - show solution

Network layer routes packets across networks: (a)-(I). Transport layer provides end-to-end (host to host / process to process) communication: (b)-(III). Data link layer does framing and error detection on a link: (c)-(II). Answer: (B).

Concept: Layer responsibilities. "Host to host" is the transport layer's end-to-end role; error handling also exists at transport, but framing pins (II) to the data link layer.

Q17MCQ1 mark · -1/3· Moderate

g(.) is a function from A to B, f(.) is a function from B to C, and their composition defined as f(g(.)) is a mapping from A to C. If f(.) and f(g(.)) are onto (surjective) functions, which ONE of the following is TRUE about the function g(.)?

  1. (A)g(.) must be an onto (surjective) function.
  2. (B)g(.) must be a one-to-one (injective) function.
  3. (C)g(.) must be a bijective function, that is, both one-to-one and onto.
  4. (D)g(.) is not required to be a one-to-one or onto function.
Answer: D - show solution

Counterexample for onto: A = {1}, B = {1, 2}, C = {c}, g(1) = 1, f(1) = f(2) = c. f and f∘g are onto, but g misses 2. Counterexample for one-to-one: A = {1, 2}, B = {1}, C = {c}, g(1) = g(2) = 1, f(1) = c. f and f∘g are onto, but g is not injective. So g need be neither. Answer: (D).

Concept: If f∘g is onto then f must be onto; nothing follows about g. The trap is reversing the rule (that holds for injectivity: f∘g injective implies g injective).

Q18MCQ1 mark · -1/3· Easy

Let G be any undirected graph with positive edge weights, and T be a minimum spanning tree of G. For any two vertices, u and v, let d1(u, v) and d2(u, v) be the shortest distances between u and v in G and T, respectively. Which ONE of the options is CORRECT for all possible G, T, u and v?

  1. (A)d1(u, v) = d2(u, v)
  2. (B)d1(u, v) ≤ d2(u, v)
  3. (C)d1(u, v) ≥ d2(u, v)
  4. (D)d1(u, v) ≠ d2(u, v)
Answer: B - show solution

T is a subgraph of G, so the unique u-v path in T is also a path in G. The shortest u-v distance in G is at most the length of that path: d1 ≤ d2. Equality need not hold: in a triangle with weights 2, 2, 3, the MST drops the 3-edge, and its endpoints are 3 apart in G but 4 apart in T. Equality can also hold (u, v adjacent by an MST edge), so (D) fails. Answer: (B).

Concept: An MST minimises total weight, not pairwise distances; it is not a shortest-path tree. Removing edges can only lengthen shortest paths.

Q19MCQ1 mark · -1/3· Easy

Consider the following context-free grammar G, where S, A, and B are the variables (non-terminals), a and b are the terminal symbols, S is the start variable, and the rules of G are described as: S → aaB | Abb A → a | aA B → b | bB Which ONE of the languages L(G) is accepted by G?

  1. (A)L(G) = {a²bⁿ | n ≥ 1} ∪ {aⁿb² | n ≥ 1}
  2. (B)L(G) = {aⁿb²ⁿ | n ≥ 1} ∪ {a²ⁿbⁿ | n ≥ 1}
  3. (C)L(G) = {aⁿbⁿ | n ≥ 1}
  4. (D)L(G) = {a²ⁿb²ⁿ | n ≥ 1}
Answer: A - show solution

A generates a⁺ = {aⁿ | n ≥ 1} and B generates b⁺ = {bⁿ | n ≥ 1}. So S → aaB gives a²bⁿ (n ≥ 1) and S → Abb gives aⁿb² (n ≥ 1). L(G) = {a²bⁿ | n ≥ 1} ∪ {aⁿb² | n ≥ 1}. Answer: (A).

Concept: Read what each non-terminal derives, then combine. The trap is assuming counts are linked (aⁿbⁿ-style) when A and B grow independently.

Q20MCQ1 mark · -1/3· Moderate

Consider the following recurrence relation: T(n) = 2T(n - 1) + n·2ⁿ for n > 0, T(0) = 1. Which ONE of the following options is CORRECT?

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

Divide by 2ⁿ: let U(n) = T(n)/2ⁿ. Then U(n) = U(n - 1) + n with U(0) = 1. So U(n) = 1 + (1 + 2 + ... + n) = 1 + n(n + 1)/2 = Θ(n²). Hence T(n) = 2ⁿ U(n) = Θ(n²2ⁿ). Answer: (A).

Concept: Normalising by the homogeneous solution 2ⁿ turns it into a sum. The trap is Θ(n2ⁿ), ignoring that the n·2ⁿ term accumulates over n levels.

Q21MSQ1 mark · no negative· Moderate

Consider the following B⁺ tree with 5 nodes, in which a node can store at most 3 key values. The value 23 is now inserted in the B⁺ tree. Which of the following option(s) is/are CORRECT? Tree (as printed): Root: [6 | 12 | 19] Leaves, left to right: [1 | 4 | 3], [7 | 9 | 10], [13 | 15 | 17], [20 | 21 | 22]

  1. (A)None of the nodes will split.
  2. (B)At least one node will split and redistribute.
  3. (C)The total number of nodes will remain same.
  4. (D)The height of the tree will increase.
Answer: B, D - show solution

23 > 19, so it goes to the rightmost leaf [20, 21, 22], which is already full (3 keys). The leaf splits, e.g. into [20, 21] and [22, 23], and a separator (22) must be pushed into the root. The root [6, 12, 19] is also full, so it splits too, and a new root is created above the two halves. Nodes go from 5 to 8 and the height grows by one level. So (A) and (C) are false; (B) and (D) are true. Answer: (B), (D).

Concept: B⁺ tree insertion: a full leaf splits and pushes a key up; a full parent splits recursively, and a root split is the only way height increases. Every node on the path here is full.

Q22MSQ1 mark · no negative· Easy

Consider 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?

  1. (A)P3: SYN = 1, ACK = 1
  2. (B)P2: SYN = 1, ACK = 1
  3. (C)P2: SYN = 0, ACK = 1
  4. (D)P1: SYN = 1
Answer: B, D - show solution

P1 (client to server): SYN = 1, ACK = 0. P2 (server to client): SYN = 1, ACK = 1 (SYN-ACK). P3 (client to server): SYN = 0, ACK = 1. So (B) and (D) are true; (A) wrongly sets SYN in P3 and (C) wrongly clears SYN in P2. Answer: (B), (D).

Concept: Handshake flags: SYN, SYN+ACK, ACK. SYN consumes a sequence number and appears only in the first two segments.

Q23MSQ1 mark · no negative· Moderate

Consider the given system of linear equations for variables x and y, where k is a real-valued constant. Which of the following option(s) is/are CORRECT? x + ky = 1 kx + y = -1

  1. (A)There is exactly one value of k for which the above system of equations has no solution.
  2. (B)There exist an infinite number of values of k for which the system of equations has no solution.
  3. (C)There exists exactly one value of k for which the system of equations has exactly one solution.
  4. (D)There exists exactly one value of k for which the system of equations has an infinite number of solutions.
Answer: A, D - show solution

Determinant = 1 - k². If k ≠ ±1 there is a unique solution, so infinitely many k give exactly one solution: (C) false. k = 1: x + y = 1 and x + y = -1 are inconsistent: no solution. k = -1: x - y = 1 and -x + y = -1 are the same line: infinitely many solutions. So exactly one k (k = 1) gives no solution: (A) true, (B) false; exactly one k (k = -1) gives infinitely many: (D) true. Answer: (A), (D).

Concept: Singular coefficient matrix means no solution or infinitely many, decided by consistency of the right-hand side. Check each singular k separately rather than assuming both behave alike.

Q24MSQ1 mark · no negative· Hard

Let X be a 3-variable Boolean function that produces output as '1' when at least two of the input variables are '1'. Which of the following statement(s) is/are CORRECT, where a, b, c, d, e are Boolean variables?

  1. (A)X(a, b, X(c, d, e)) = X(X(a, b, c), d, e)
  2. (B)X(a, b, X(a, b, c)) = X(a, b, c)
  3. (C)X(a, b, X(a, c, d)) = (X(a, b, a) AND X(c, d, c))
  4. (D)X(a, b, c) = X(a, X(a, b, c), X(a, c, c))
Answer: B, D - show solution

X is the majority function; X(p, q, p) = p. (A) a = b = 1, c = d = e = 0: LHS = X(1, 1, 0) = 1, RHS = X(1, 0, 0) = 0. False. (B) If a = b the result is a, which equals X(a, b, c); if a ≠ b the third argument decides, giving X(a, b, c). True. (C) RHS = a AND c. With a = b = 1, c = d = 0: LHS = X(1, 1, 0) = 1, RHS = 0. False. (D) X(a, c, c) = c; let m = X(a, b, c). X(a, m, c): if a = c the result is a = c = m; if a ≠ c the result is m. Always m. True. Answer: (B), (D).

Concept: Majority-function identities; use X(p, q, p) = p and case-split on equal arguments. The trap is assuming majority is associative like AND/OR - it is not.

Q25MSQ1 mark · no negative· Easy

The number -6 can be represented as 1010 in 4-bit 2's complement representation. Which of the following is/are CORRECT 2's complement representation(s) of -6?

  1. (A)1000 1010 in 8-bits
  2. (B)1111 1010 in 8-bits
  3. (C)1000 0000 0000 1010 in 16-bits
  4. (D)1111 1111 1111 1010 in 16-bits
Answer: B, D - show solution

Widening a 2's complement number uses sign extension: copy the sign bit (1) into all new high bits. 1010 becomes 1111 1010 in 8 bits and 1111 1111 1111 1010 in 16 bits. Check: 1111 1010 = -128 + 122 = -6. 1000 1010 = -128 + 10 = -118, not -6. Answer: (B), (D).

Concept: Sign extension. The trap is padding with zeros after the sign bit, which works for sign-magnitude, not 2's complement.

Q26MSQ1 mark · no negative· Easy

Which of the following statement(s) is/are TRUE for any binary search tree (BST) having n distinct integers?

  1. (A)The maximum length of a path from the root node to any other node is (n - 1).
  2. (B)An inorder traversal will always produce a sorted sequence of elements.
  3. (C)Finding an element takes O(log₂ n) time in the worst case.
  4. (D)Every BST is also a Min-Heap.
Answer: A, B - show solution

(A) A path from the root can visit at most all n nodes, i.e. n - 1 edges, reached by a skewed tree: true as the maximum. (B) Inorder visits left subtree, root, right subtree, which is ascending order by the BST property: true. (C) A skewed BST needs O(n) search, so O(log n) worst case is false. (D) In a BST the left child is smaller than the parent, violating the min-heap property: false. Answer: (A), (B).

Concept: BST height ranges from log n to n - 1; only balanced BSTs guarantee logarithmic search. Inorder-sorted is the defining BST property.

Q27MSQ1 mark · no negative· Easy

A 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? Data path (from the figure): Mux_A selects between register RA and a 32-bit immediate value (control: Select RA/immediate). Mux_B selects between register RB and a 32-bit immediate value (control: Select RB/immediate). The outputs of Mux_A and Mux_B are the two ALU inputs (ALU control lines select the operation), and the ALU output is written to RZ.

  1. (A)The data path can implement arithmetic operations involving two registers.
  2. (B)The data path can implement arithmetic operations involving one register and one immediate value.
  3. (C)The data path can implement arithmetic operations involving two immediate values.
  4. (D)The data path can only implement arithmetic operations involving one register and one immediate value.
Answer: A, B, C - show solution

Each ALU input has its own mux with an independent select. RA and RB selected: register-register (A). RA with immediate on Mux_B, or immediate on Mux_A with RB: register-immediate (B). Both muxes on immediates: two immediate values (C). Since all three combinations are possible, the word "only" makes (D) false. Answer: (A), (B), (C).

Concept: Enumerate the mux select combinations: 2 x 2 = 4 input pairings. The trap is (D), which ignores that each mux can still pick its register.

Q28MSQ1 mark · no negative· Easy

A regular language L is accepted by a non-deterministic finite automaton (NFA) with n states. Which of the following statement(s) is/are FALSE?

  1. (A)L may have an accepting NFA with < n states.
  2. (B)L may have an accepting DFA with < n states.
  3. (C)There exists a DFA with ≤ 2ⁿ states that accepts L.
  4. (D)Every DFA that accepts L has > 2ⁿ states.
Answer: D - show solution

The given NFA need not be minimal, so a smaller NFA or even a smaller DFA may exist: (A) and (B) are true (they only say "may"). The subset construction gives a DFA with at most 2ⁿ states: (C) true. (D) contradicts (C), since a DFA with at most 2ⁿ states always exists: (D) is false. Answer: (D).

Concept: Subset construction bound: an n-state NFA yields a DFA with at most 2ⁿ states. Watch the question asks for FALSE statements.

Q29NAT1 mark · no negative· Easy

Suppose 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 - show solution

Each I/O call sends the process to the I/O queue; when the I/O completes it returns to the ready queue. I/O operations: one scanf, plus printf executed 20 times in the loop = 21 I/O operations. Each produces one entry into the ready queue. return 0 terminates the process, no further entry. Answer: 21.

Concept: Process state transitions: running to waiting on I/O, waiting to ready on completion. Traps: forgetting the scanf (20) or counting the initial admission.

Q30NAT1 mark · no negative· Easy

Let S be the set of all ternary strings defined over the alphabet {a, b, c}. Consider all strings in S 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 - show solution

Complement count. Total strings of length 5: 3⁵ = 243. Strings with no two equal adjacent symbols: 3 choices for the first, then 2 for each of the next 4 (anything but the previous symbol): 3 x 2⁴ = 48. Strings with at least one equal adjacent pair: 243 - 48 = 195. Answer: 195.

Concept: "At least one" counts are easiest via the complement. Direct counting of aa/bb/cc occurrences double-counts strings with several pairs.

Q31NAT1 mark · no negative· Easy

Consider the given function f(x). f(x) = ax + b for x < 1 f(x) = x³ + x² + 1 for x ≥ 1 If the function is differentiable everywhere, the value of b must be ________. (rounded off to one decimal place)

Answer: -2.1 to -1.9 - show solution

Continuity at x = 1: a + b = 1 + 1 + 1 = 3. Differentiability at x = 1: left derivative a equals right derivative 3x² + 2x at x = 1, which is 5. So a = 5 and b = 3 - 5 = -2. Answer: -2.0.

Concept: Differentiable at a join needs both continuity (values match) and equal one-sided derivatives. Using only one condition leaves b undetermined.

Q32NAT1 mark · no negative· Easy

A box contains 5 coins: 4 regular coins and 1 fake coin. When a regular coin is tossed, the probability P(head) = 0.5 and for a fake coin, P(head) = 1. 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 - show solution

P(fake) = 1/5, P(HH | fake) = 1. P(regular) = 4/5, P(HH | regular) = 0.25. P(HH) = 0.2 x 1 + 0.8 x 0.25 = 0.2 + 0.2 = 0.4. By Bayes, P(fake | HH) = 0.2 / 0.4 = 0.5. Answer: 0.50.

Concept: Bayes' theorem: posterior = likelihood x prior / evidence. The trap is answering the prior 0.2, ignoring that two heads is much likelier with the fake coin.

Q33NAT1 mark · no negative· Easy

The pseudocode of a function fun() is given below. Let A[0, ... ,29] be an array storing 30 distinct integers in descending order. The number of swap operations that will be performed, if the function fun() is called with A[0, ... ,29] as argument, 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 - show solution

fun() is bubble sort; each swap removes exactly one inversion. A descending array of n distinct values has every pair inverted: n(n - 1)/2 inversions. For n = 30: 30 x 29 / 2 = 435 swaps. Answer: 435.

Concept: Bubble sort swaps = number of inversions. Reverse-sorted input is the worst case, giving the maximum C(n, 2).

Q34NAT1 mark · no negative· Easy

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 - show solution

z holds the address of a. foo receives a copy of that address in p and the value 25 in x. *p = x writes 25 into the location p points to, which is a. So a becomes 25 and the program prints 25. Answer: 25.

Concept: Passing a pointer lets a function modify the caller's variable. The trap is thinking call-by-value leaves a at 20 - the pointer is copied, but it still points to a.

Q35NAT1 mark · no negative· Easy

The 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 T stores 32 keys. The height of T is _____________. (Answer in integer)

Answer: 5 - show solution

A binary heap is a complete binary tree. Levels 0 to 4 hold 1 + 2 + 4 + 8 + 16 = 31 nodes, so the 32nd key starts level 5. Height = floor(log₂ 32) = 5 edges. Answer: 5.

Concept: Heap height is floor(log₂ n). The trap is ceil(log₂ 32) - 1 = 4, forgetting that 32 nodes overflow a perfect tree of height 4 (31 nodes).

Q36MCQ2 marks · -2/3· Easy

Consider 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, 1K = 2¹⁰, 1M = 2²⁰.]

  1. (A)6 × 2¹⁰
  2. (B)8 × 2¹⁰
  3. (C)2¹²
  4. (D)2¹⁴
Answer: A - show solution

Block offset: 16 = 2⁴ bytes, 4 bits. Number of cache lines: 16K / 16 = 2¹⁰, so 10 index bits. Tag = 20 - 10 - 4 = 6 bits. One tag per line: 6 x 2¹⁰ bits in total. Answer: 6 × 2¹⁰ (A).

Concept: Direct-mapped address split: tag | index | offset. Tag storage = tag bits x number of lines. Trap: using cache bytes instead of lines as the multiplier.

Q37MCQ2 marks · -2/3· Easy

A 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

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

Opcode: 50 instruction types need ceil(log₂ 50) = 6 bits. Register field: 64 registers need 6 bits (R1 is both source and destination, one field). Immediate: 32 - 6 - 6 = 20 bits. Answer: 20 (B).

Concept: Instruction format field widths. The trap is allotting two register fields (giving 14) when the instruction names only one register.

Q38MCQ2 marks · -2/3· Moderate

A computer has two processors, M1 and M2. Four processes P1, P2, P3, P4 with CPU bursts of 20, 16, 25, and 10 milliseconds, respectively, arrive at the same time and these are the only processes in the system. The scheduler uses non-preemptive priority scheduling, with priorities decided as follows: - M1 uses priority of execution for the processes as, P1 > P3 > P2 > P4, i.e., P1 and P4 have highest and lowest priorities, respectively. - M2 uses priority of execution for the processes as, P2 > P3 > P4 > P1, i.e., P2 and P1 have highest and lowest priorities, respectively. A process Pi is scheduled to a processor Mk, if the processor is free and no other process Pj is waiting with higher priority. At any given point of time, a process can be allocated to any one of the free processors without violating the execution priority rules. Ignore the context switch time. What will be the average waiting time of the processes in milliseconds?

  1. (A)9.00
  2. (B)8.75
  3. (C)6.50
  4. (D)7.50
Answer: A - show solution

t = 0: both free. M1 takes its top choice P1 (0-20); M2 takes its top choice P2 (0-16). t = 16: M2 free, waiting P3 and P4; by M2's order P3 > P4, so P3 runs 16-41. t = 20: M1 free, only P4 waits, P4 runs 20-30. Waiting times: P1 0, P2 0, P3 16, P4 20. Average = 36 / 4 = 9.00 ms. Answer: 9.00 (A).

Concept: Multiprocessor non-preemptive priority with per-processor priority orders. The key step is applying M2's order at t = 16, not M1's.

Q39MCQ2 marks · -2/3· Easy

Consider two relations describing teams and players in a sports league: - teams(tid, tname): tid, tname are team-id and team-name, respectively - players(pid, pname, tid): pid, pname, and tid denote player-id, player-name and the team-id of the player, respectively Which ONE of the following tuple relational calculus queries returns the name of the players who play for the team having tname as 'MI'?

  1. (A){ p.pname | p ∈ players ∧ ∃t (t ∈ teams ∧ p.tid = t.tid ∧ t.tname = 'MI') }
  2. (B){ p.pname | p ∈ teams ∧ ∃t (t ∈ players ∧ p.tid = t.tid ∧ t.tname = 'MI') }
  3. (C){ p.pname | p ∈ players ∧ ∃t (t ∈ teams ∧ t.tname = 'MI') }
  4. (D){ p.pname | p ∈ teams ∧ ∃t (t ∈ players ∧ t.tname = 'MI') }
Answer: A - show solution

p must range over players (it supplies pname), and there must exist a team t with the same tid whose tname is 'MI'. That is exactly (A). (B) and (D) range p over teams, which has no pname. (C) drops the join p.tid = t.tid, so it returns every player whenever an MI team exists. Answer: (A).

Concept: TRC joins need an explicit equality on the linking attribute. Missing the join condition gives all tuples when the existential is satisfiable.

Q40MCQ2 marks · -2/3· Easy

A packet with the 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

  1. (A)E3
  2. (B)E1
  3. (C)E2
  4. (D)E5
Answer: A - show solution

Third octet 109 = 01101101. /16 145.36.0.0: first 16 bits match, so E1 is a candidate. /17 145.36.128.0 needs third-octet top bit 1; 109 has 0: no. /18 145.36.64.0 needs top two bits 01; 109 starts 01: match. /24 145.36.255.0 needs third octet 255: no. Longest prefix match is /18. Answer: E3 (A).

Concept: Longest prefix match. The trap is stopping at the first matching entry (/16, E1) instead of choosing the most specific match.

Q41MCQ2 marks · -2/3· Easy

Let A be a 2 × 2 matrix as given. A = [ 1 1 ] [ 1 -1 ] What are the eigenvalues of the matrix A¹³?

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

Characteristic equation of A: (1 - λ)(-1 - λ) - 1 = λ² - 2 = 0, so λ = ±√2. Eigenvalues of A¹³ are λ¹³ = (±√2)¹³ = ±2⁶√2 = ±64√2. (Also A² = 2I, so A¹³ = 2⁶A = 64A.) Answer: 64√2, -64√2 (D).

Concept: Eigenvalues of Aᵏ are λᵏ. The odd power keeps the signs; the trap is dropping the extra √2 factor (answering ±64).

Q42MCQ2 marks · -2/3· Moderate

Consider the following four variable Boolean function in sum-of-product form F(b3, b2, b1, b0) = Σ(0, 2, 4, 8, 10, 11, 12) where the value of the function is computed by considering b3b2b1b0 as a 4-bit binary number, where b3 denotes the most significant bit and b0 denotes the least significant bit. Note that there are no don't care terms. Which ONE of the following options is the CORRECT minimized Boolean expression for F? (In the options, x' denotes the complement of x.)

  1. (A)b1'b0' + b2'b0' + b1b2'b3
  2. (B)b1'b0' + b2'b0'
  3. (C)b2'b0' + b1b2b3
  4. (D)b0'b2' + b3'
Answer: A - show solution

(x' denotes NOT x.) b1'b0' (b1 = 0, b0 = 0) covers 0, 4, 8, 12. b2'b0' (b2 = 0, b0 = 0) covers 0, 2, 8, 10. Remaining minterm 11 = 1011 pairs with 10 = 1010 to give b3 b2' b1. All three are essential prime implicants and they cover exactly the 7 minterms. Option (B) misses 11; (C) and (D) include non-minterms. Answer: b1'b0' + b2'b0' + b1b2'b3 (A).

Concept: K-map grouping with edge/corner wrap. The trap is (B): the four-corner groups look complete, but the isolated 11 needs its own pair.

Q43MCQ2 marks · -2/3· Moderate

Let G(V, E) be an undirected and unweighted graph with 100 vertices. Let d(u, v) denote the number of edges in a shortest path between vertices u and v in V. Let the maximum value of d(u, v), u, v ∈ V such that u ≠ v, be 30. Let T be any breadth-first-search tree of G. Which ONE of the given options is CORRECT for every such graph G?

  1. (A)The height of T is exactly 15.
  2. (B)The height of T is exactly 30.
  3. (C)The height of T is at least 15.
  4. (D)The height of T is at least 30.
Answer: C - show solution

A BFS tree from root r has height equal to the eccentricity e(r), the largest d(r, v). Take u, v with d(u, v) = 30. By the triangle inequality 30 ≤ d(u, r) + d(r, v) ≤ 2e(r), so e(r) ≥ 15. Height 15 occurs from a central vertex (e.g. middle of a path) and 30 from an endpoint, so neither "exactly" option holds for every G, and "at least 30" fails for a central root. Answer: (C).

Concept: BFS tree height = eccentricity of the root, which lies between radius and diameter, and radius ≥ diameter / 2. Trap: assuming BFS height always equals the diameter.

Q45MCQ2 marks · -2/3· Moderate

Consider the following two languages over the alphabet {a, b, c}, where m and n are natural numbers. L1 = { aᵐbᵐcᵐ⁺ⁿ | m, n ≥ 1 } L2 = { aᵐbⁿcᵐ⁺ⁿ | m, n ≥ 1 } Which ONE of the following statements is CORRECT?

  1. (A)Both L1 and L2 are context-free languages.
  2. (B)L1 is a context-free language but L2 is not a context-free language.
  3. (C)L1 is not a context-free language but L2 is a context-free language.
  4. (D)Neither L1 nor L2 are context-free languages.
Answer: C - show solution

L2: push one symbol per a and per b, pop one per c; accept when the stack empties exactly with n, m ≥ 1. Grammar: S → aSc | aXc, X → bXc | bc. So L2 is context-free. L1 = { aᵐbᵐcᵏ | k > m ≥ 1 } needs #a = #b and also #c > #a: two dependent comparisons. Pumping aᵖbᵖcᵖ⁺¹ breaks it: pumping a's and b's up makes them reach the c count, pumping c's down (or only c's) breaks c > a or a = b. Not context-free. Answer: (C).

Concept: One stack can check one linear relation. L2 is a nested match (c count = a's + b's); L1 needs a = b and c > a simultaneously, like aⁿbⁿcⁿ.

Q46MSQ2 marks · no negative· Easy

Which of the following statement(s) is/are TRUE while computing First and Follow during top down parsing by a compiler?

  1. (A)For a production A → ε, ε will be added to First(A).
  2. (B)If there is any input right end marker, it will be added to First(S), where S is the start symbol.
  3. (C)For a production A → ε, ε will be added to Follow(A).
  4. (D)If there is any input right end marker, it will be added to Follow(S), where S is the start symbol.
Answer: A, D - show solution

Rule for First: if A → ε is a production, ε ∈ First(A): (A) true. Rule for Follow: the end marker $ is placed in Follow(S) for the start symbol: (D) true. $ is never in a First set (it is not derived from any symbol): (B) false. Follow sets contain terminals and $, never ε: (C) false. Answer: (A), (D).

Concept: First may contain ε; Follow may contain $; never the other way round. Swapping the two is the standard trap.

Q47MSQ2 marks · no negative· Easy

Consider a relational schema team(name, city, owner), with functional dependencies {name → city, name → owner}. The relation team is decomposed into two relations, t1(name, city) and t2(name, owner). Which of the following statement(s) is/are TRUE?

  1. (A)The relation team is NOT in BCNF.
  2. (B)The relations t1 and t2 are in BCNF.
  3. (C)The decomposition constitutes a lossless join.
  4. (D)The relation team is NOT in 3NF.
Answer: B, C - show solution

name → city, owner, so name is a key of team. Every FD has a superkey on the left, so team is in BCNF (and hence 3NF): (A) and (D) false. t1 and t2 are two-attribute relations with name as key: both in BCNF, (B) true. The common attribute name is a key of t1 (and t2), so the join is lossless: (C) true. Answer: (B), (C).

Concept: BCNF: every non-trivial FD's determinant is a superkey. Lossless binary decomposition: the shared attributes must be a key of one side. Decomposing an already-BCNF relation is allowed, just unnecessary.

Q48MSQ2 marks · no negative· Moderate

Which of the following predicate logic formulae/formula is/are CORRECT representation(s) of the statement: "Everyone has exactly one mother"? The meanings of the predicates used are: - mother(y, x): y is the mother of x - noteq(x, y): x and y are not equal

  1. (A)∀x∃y∃z(mother(y, x) ∧ ¬mother(z, x))
  2. (B)∀x∃y[mother(y, x) ∧ ∀z(noteq(z, y) → ¬mother(z, x))]
  3. (C)∀x∀y[mother(y, x) → ∃z(mother(z, x) ∧ ¬noteq(z, y))]
  4. (D)∀x∃y[mother(y, x) ∧ ¬∃z(noteq(z, y) ∧ mother(z, x))]
Answer: B, D - show solution

"Exactly one" = existence plus uniqueness: for each x, some y is x's mother and no z different from y is x's mother. (B) states exactly this. (D) is the same with ∀z(p → ¬q) rewritten as ¬∃z(p ∧ q). (A) only says some y is a mother and some z is not, which allows two mothers. (C) is trivially true (take z = y) and asserts neither existence nor uniqueness. Answer: (B), (D).

Concept: Uniqueness pattern ∃y[P(y) ∧ ∀z(z ≠ y → ¬P(z))]. Recognise the equivalent ¬∃ form; reject formulas satisfied by a trivial witness.

Q49MSQ2 marks · no negative· Moderate

A = {0, 1, 2, 3, ...} is the set of non-negative integers. Let F be the set of functions from A to itself. For any two functions, f1, f2 ∈ F, we define (f1 ⊙ f2)(n) = f1(n) + f2(n) for every number n in A. Which of the following is/are CORRECT about the mathematical structure (F, ⊙)?

  1. (A)(F, ⊙) is an Abelian group.
  2. (B)(F, ⊙) is an Abelian monoid.
  3. (C)(F, ⊙) is a non-Abelian group.
  4. (D)(F, ⊙) is a non-Abelian monoid.
Answer: B - show solution

Closure: a sum of non-negative integers is a non-negative integer. Associativity and commutativity follow pointwise from + on integers. Identity: the zero function z(n) = 0. Inverses: f(n) = 1 would need g(n) = -1, which is not in A, so not a group. Hence a commutative (Abelian) monoid. Answer: (B).

Concept: Pointwise operations inherit the properties of the underlying operation on the codomain; (N, +) is a commutative monoid without inverses, so the function space is too.

Q50MSQ2 marks · no negative· Moderate

Consider the following deterministic finite automaton (DFA) defined over the alphabet, Σ = {a, b}. Identify which of the following language(s) is/are accepted by the given DFA. DFA (from the figure): states q0 (start), q1, q2, q3 (the only accepting state). q0: on a → q0, on b → q1 q1: on a → q2, on b → q1 q2: on a → q0, on b → q3 q3: on a → q2, on b → q1

  1. (A)The set of all strings containing an even number of b's.
  2. (B)The set of all strings containing the pattern bab.
  3. (C)The set of all strings ending with the pattern bab.
  4. (D)The set of all strings not containing the pattern aba.
Answer: C - show solution

Interpret states as the longest suffix matching a prefix of bab: q0 = none, q1 = b, q2 = ba, q3 = bab. Check transitions: from ba, a gives baa (no useful suffix) → q0; from bab, a gives suffix ba → q2, b gives suffix b → q1. So the DFA accepts exactly strings ending in bab. (B) fails: baba contains bab but ends in q2. (A) fails: bab has two b's yet bb is rejected. (D) fails: abab contains aba yet ends in bab and is accepted. Answer: (C).

Concept: Pattern-matching DFAs track the longest suffix that is a prefix of the pattern. "Contains" needs a trap accepting state; returning out of the final state means "ends with".

Q51NAT2 marks · no negative· Moderate

A disk of size 512M bytes is divided into blocks of 64K bytes. A file is stored in the disk using linked allocation. In linked allocation, each data block reserves 4 bytes to store the pointer to the next data block. The link part of the last data block contains a NULL pointer (also of 4 bytes). Suppose a file of 1M bytes needs to be stored in the disk. Assume, 1K = 2¹⁰ and 1M = 2²⁰. The amount of space in bytes that will be wasted due to internal fragmentation is ______. (Answer in integer)

Answer: 65468 - show solution

Data per block = 65536 - 4 = 65532 bytes. File = 1048576 bytes. 16 blocks hold 16 x 65532 = 1048512 bytes, leaving 64 bytes, so a 17th block is needed. That block uses 64 data bytes out of 65532, wasting 65532 - 64 = 65468 bytes. Answer: 65468.

Concept: Internal fragmentation is the unused data area of the last block. The trap is ignoring the 4-byte pointer (16 blocks would seem to fit exactly, giving 0).

Q52NAT2 marks · no negative· Easy

Refer to the given 3-address code sequence. This code sequence is 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 1013
Answer: 6 - show solution

Leaders: the first statement 1001; jump targets 1003, 1002, 1013; statements after jumps 1010, 1012 (1018 does not exist). Sorted leaders: 1001, 1002, 1003, 1010, 1012, 1013. Blocks: [1001], [1002], [1003-1009], [1010-1011], [1012], [1013-1017]. Answer: 6.

Concept: Leader rules: first instruction, every jump target, every instruction following a jump. Commonly missed: 1002 as a target, making 1001 a block by itself.

Q53NAT2 marks · no negative· Easy

A computer has a memory hierarchy consisting of two-level cache (L1 and L2) and a main memory. If the processor needs to access data from memory, it first looks into L1 cache. If the data is not found in L1 cache, it goes to L2 cache. If it fails to get the data from L2 cache, it goes to main memory, where the data is definitely available. Hit rates and access times of various memory units are shown in the figure. The average memory access time in nanoseconds (ns) is ________. (rounded off to two decimal places) Figure data: L1 cache: hit rate = 95%, access time = 10 ns L2 cache: hit rate = 85%, access time (including L1 cache miss penalty) = 20 ns Main memory: access time (including L1 and L2 cache miss penalty) = 200 ns

Answer: 11.83 to 11.87 - show solution

Each access time already includes the earlier misses, so weight each by the probability that the access is served there. L1: 0.95 x 10 = 9.5. L2: 0.05 x 0.85 x 20 = 0.85. Memory: 0.05 x 0.15 x 200 = 1.5. AMAT = 9.5 + 0.85 + 1.5 = 11.85 ns. Answer: 11.85.

Concept: When given times include miss penalties, do not add L1 and L2 times again. The trap is the hierarchical sum 10 + 0.05(20 + 0.15 x 200), which double counts.

Q54NAT2 marks · no negative· Moderate

In optimal page replacement algorithm, information about all future page references is available to the operating system (OS). A modification of the optimal page replacement algorithm is as follows: The OS correctly predicts only up to next 4 page references (including the current page) at the time of allocating a frame to a page. A process accesses the pages in the following order of page numbers: 1, 3, 2, 4, 2, 3, 1, 2, 4, 3, 1, 4. If the system has three memory frames that are initially empty, the number of page faults that will occur during execution of the process is ________. (Answer in integer)

Answer: 6 - show solution

1, 3, 2: 3 faults, frames {1, 3, 2}. Ref 4 (4th): window 4, 2, 3, 1 - all resident pages appear; 1 is used last, replace 1: {4, 3, 2}. 2, 3 hit. Ref 1 (7th): window 1, 2, 4, 3; 3 used last, replace 3: {4, 1, 2}. 2, 4 hit. Ref 3 (10th): window 3, 1, 4 (end of string); 2 does not appear, replace 2: {4, 1, 3}. 1, 4 hit. Faults: 3 + 1 + 1 + 1 = 6. Answer: 6.

Concept: Optimal replacement limited to a lookahead window: evict a page absent from the window, else the one used furthest within it. Here the window never misleads, so the count matches full OPT.

Q55NAT2 marks · no negative· Easy

Consider the following database tables of a sports league. player(pid, pname, age) team(tid, tname, city, cid) coach(cid, cname) members(pid, tid) An instance of the table and an SQL query are given. player: (1, Jasprit, 31), (2, Atharva, 24), (3, Ishan, 26), (4, Axar, 30) coach: (101, Ricky), (102, Mark), (103, Trevor) team: (10, MI, Mumbai, 102), (20, DC, Delhi, 101), (30, PK, Mohali, 103) members: (1, 10), (2, 30), (3, 10), (4, 20) The value returned by the given SQL query is ______. (Answer in integer)

SELECT 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 - show solution

Mark has cid 102. The team with cid 102 is tid 10 (MI). Members of team 10: pids 1 and 3. Their ages: Jasprit 31, Ishan 26. MIN(age) = 26. Answer: 26.

Concept: Nested IN subquery with a three-way join. Trap: matching coach id to the wrong team or taking the minimum over all players (24).

Q56NAT2 marks · no negative· Easy

Suppose a 5-bit message is transmitted from a source to a destination through a noisy channel. The probability that a bit of the message gets flipped during transmission is 0.01. Flipping of each bit is independent of one another. The probability that the message is delivered error-free to the destination is ______. (rounded off to three decimal places)

Answer: 0.949 to 0.952 - show solution

Each bit arrives correctly with probability 0.99, independently. All 5 correct: 0.99⁵ = 0.95099..., which rounds to 0.951. Answer: 0.951.

Concept: Independent events multiply. The trap is 1 - 5 x 0.01 = 0.95, a first-order approximation that is slightly off at three decimals.

Q57NAT2 marks · no negative· Moderate

Suppose a message of size 15000 bytes is transmitted from a source to a destination using IPv4 protocol via two routers as shown in the figure. Each router has a defined maximum transmission unit (MTU) as shown in the figure, including IP header. The number of fragments that will be delivered to the destination is ________. (Answer in integer) Figure: Source → Router-1 (MTU = 5000 bytes) → Router-2 (MTU = 3000 bytes) → Destination

Answer: 7 - show solution

Assume a 20-byte IP header; fragment data (except the last) must be a multiple of 8. At MTU 5000: max data 4980, rounded down to 4976. 15000 = 3 x 4976 + 72, giving 4 fragments: 4976, 4976, 4976, 72. At MTU 3000: max data 2980, rounded down to 2976. Each 4976 fragment splits into 2976 + 2000 (2 fragments); the 72-byte one passes unchanged. Total = 3 x 2 + 1 = 7. Answer: 7.

Concept: IPv4 fragmentation: payload per fragment is (MTU - header) rounded down to a multiple of 8, and fragments are never reassembled at routers. Trap: dividing 15000 directly by the smallest MTU (6).

Q58NAT2 marks · no negative· Easy

Consider a probability distribution given by the density function P(x). P(x) = Cx² for 1 ≤ x ≤ 4 P(x) = 0 for x < 1 or x > 4 The probability that x lies between 2 and 3, i.e., P(2 ≤ x ≤ 3) is __________. (rounded off to three decimal places)

Answer: 0.3 to 0.302 - show solution

Normalise: ∫ from 1 to 4 of Cx² dx = C(64 - 1)/3 = 21C = 1, so C = 1/21. P(2 ≤ x ≤ 3) = (1/21) ∫ from 2 to 3 of x² dx = (1/21)(27 - 8)/3 = 19/63 ≈ 0.302. Answer: 0.302 (accepted range 0.300 to 0.302).

Concept: Find the constant from total probability 1, then integrate over the interval. Trap: forgetting to normalise.

Q59NAT2 marks · no negative· Moderate

Consider a finite state machine (FSM) with one input X and one output f, represented by the given state transition table. The minimum number of states required to realize this FSM is ________. (Answer in integer) Present Next state Output f state X=0 X=1 X=0 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 0

Answer: 5 - show solution

Partition by outputs: P1 = {A, B, C, E} (00), {D, H} (10), {F} (11), {G} (01). Refine by next-state classes. D: (G, A), H: (G, A): identical, D ≡ H. In P1: A → (F, P1), C → (F, P1), B → (DH, P1), E → (DH, P1): split into {A, C} and {B, E}. B and E both go to (D, C): equivalent. A → (F, B) and C → (F, E) with B ≡ E: equivalent. Final classes {A, C}, {B, E}, {D, H}, {F}, {G}. Answer: 5.

Concept: State minimisation by partition refinement: start from output classes and split until next-state classes agree. Equivalences can depend on each other (A ≡ C needs B ≡ E).

Q60NAT2 marks · no negative· Moderate

Consider 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) Circuit (from the figure): four D flip-flops D0, D1, D2, D3 on a common clock, connected as a shift register: D1 = Q0, D2 = Q1, D3 = Q2, and the complemented output of the last stage is fed back to the first, D0 = Q3'.

Answer: 7 to 8 - show solution

A shift register with the inverted last output fed back is a Johnson (twisted ring) counter. With n = 4 flip-flops it cycles through 2n = 8 states, e.g. 0000 → 1000 → 1100 → 1110 → 1111 → 0111 → 0011 → 0001 → 0000 (Q0Q1Q2Q3). The 16 states split into two cycles of 8, so from any initial value the circuit returns after 8 clocks. Answer: 8 (7 also accepted by the official key, if the initial state is not counted).

Concept: Ring counter (Q3 fed back) has n states; Johnson counter (Q3' fed back) has 2n. The official range 7-8 reflects whether the initial state is counted.

Q61NAT2 marks · no negative· Easy

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 - show solution

foo adds 1 for every adjacent pair that differs, and 1 for the last element, i.e. it counts runs of equal values. Array: 0 | 1 | 2 2 2 | 0 0 | 1 1. Differing adjacent pairs: 0-1, 1-2, 2-0, 0-1 = 4, plus 1 at size 1. Total 5 (the number of runs). Answer: 5.

Concept: Recognise the recursion's meaning (count of maximal runs) instead of tracing nine calls. Trap: forgetting the base case returns 1, not 0.

Q62NAT2 marks · no negative· Moderate

Let LIST be a datatype for an implementation of linked list (definition below). Suppose a program has created two linked lists, L1 and L2, whose contents are given below (code for creating L1 and L2 is not provided here). L1 contains 9 nodes, and L2 contains 7 nodes. L1: 1 → 7 → 12 → 3 → 9 → 5 → 11 → 15 → 8 → NULL L2: 1 → 11 → 6 → 9 → 15 → 12 → 4 → NULL Consider the following C program segment that modifies the list L1. The number of nodes that will be there in L1 after the execution of the code segment is ________. (Answer in integer)

typedef struct list {
    int data;
    struct list *next;
} LIST;

int 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;
        else ptr1 = ptr1->next;
    }
    ... ... ...
    return 0;
}
Answer: 5 - show solution

The loop deletes every node after the head whose value occurs in L2; the head itself (1) is never tested. L2 values: {1, 11, 6, 9, 15, 12, 4}. Walk L1 after the head: 7 keep, 12 delete, 3 keep, 9 delete, 5 keep, 11 delete, 15 delete, 8 keep. Remaining: 1 → 7 → 3 → 5 → 8. Answer: 5.

Concept: Deleting via ptr1->next without advancing ptr1 handles consecutive deletions (11, 15). Trap: deleting the head 1 as well (giving 4), though only next nodes are ever checked.

Q63NAT2 marks · no negative· Easy

Consider the following 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 - show solution

First loop: t becomes 100000, then t /= 10 gives 10000, the place value of the leading digit. Second loop extracts digits left to right: 1, 4, 3, 6, 2, with turn = 0, 1, 0, 1, 0. Only digits with turn = 1 are appended: 4 then 6, so newnum = 46. Answer: 46.

Concept: The function keeps the 2nd, 4th, ... digits from the left. Trap: starting turn at 1 (giving 132) or reading digits right to left.

Q64NAT2 marks · no negative· Moderate

The maximum value of x 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) Graph (from the figure): vertices A, B, C, D with edges A-B = 7, A-D = 6, D-C = 8, B-C = x, B-D = 1, A-C = 3.

Answer: 5 - show solution

Edge BC is in every MST iff it is strictly lighter than the heaviest edge on every other B-C path (cycle property). Other B-C paths and their maximum edge: B-A-C max(7, 3) = 7; B-D-C max(1, 8) = 8; B-D-A-C max(1, 6, 3) = 6; B-A-D-C max(7, 6, 8) = 8. The smallest of these is 6, so we need x < 6. At x = 6, the MST {BD, AC, AD} avoids BC. Largest integer: x = 5. Answer: 5.

Concept: An edge is in every MST iff every alternative path between its endpoints contains an edge strictly heavier than it. Trap: answering 6, where a tie lets another MST exclude BC.

Q65NAT2 marks · no negative· Easy

In a double hashing scheme, h1(k) = k mod 11 and h2(k) = 1 + (k mod 7) are the auxiliary hash functions. The size m of the hash table is 11. The hash function for the i-th probe in the open address table is [h1(k) + i·h2(k)] mod m. The following keys are inserted in the given order: 63, 50, 25, 79, 67, 24. The slot at which key 24 gets stored is ___________. (Answer in integer)

Answer: 10 to 11 - show solution

63 mod 11 = 8 → slot 8. 50 mod 11 = 6 → slot 6. 25 mod 11 = 3 → slot 3. 79 mod 11 = 2 → slot 2. 67 mod 11 = 1 → slot 1. 24: h1 = 2 (occupied), h2 = 1 + (24 mod 7) = 1 + 3 = 4. i = 1: (2 + 4) mod 11 = 6 (occupied). i = 2: (2 + 8) mod 11 = 10, free. Key 24 goes to slot 10. Answer: 10.

Concept: Double hashing steps by h2(k) on each collision. Traps: using linear probing (slot 4) or forgetting h2 adds 1 to k mod 7.

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