GATE CS 2026 Set 2 — All 65 Questions with Solutions

Computer Science (CS). Every question from this paper with the official answer key and a step-by-step solution. 100 marks total.

  1. Question 1General Aptitudemcq1 mark
    Expedite, Hasten, Hurry, __________ Fill the blank by choosing a word with a meaning similar to that of the words given above.
    • A.
      Accelerate
      ✓
    • B.
      Retard
    • C.
      Provide
    • D.
      Disable

    Answer: A

    Solution

    Answer: (A) All the given words mean to speed up. Among the options, only Accelerate carries the same meaning; Retard means to slow down, and Provide/Disable are unrelated.
  2. Question 2General Aptitudemcq1 mark
    A black square PQRS has been cut into two parts. One part of it is shown in Panel I. Which one of the shapes in Panel II is the other part?
    GATE CS 2026 Set 2 Question 2 figure
    • A.
      (i)
    • B.
      (ii)
    • C.
      (iii)
      ✓
    • D.
      (iv)

    Answer: C

    Solution

    Answer: (C) Placing each candidate shape against the part shown in Panel I, only shape (iii) fills the remaining region so that the two pieces together reform the complete solid black square PQRS without overlap or gap.
  3. Question 3General Aptitudemcq1 mark
    A day can only be cloudy or sunny. The probability of a day being cloudy is 0.5, independent of the condition on other days. What is the probability that in any given four days, there will be three cloudy days and one sunny day?
    • A.
      ✓
    • B.
    • C.
    • D.

    Answer: A

    Solution

    Answer: (A) This is a binomial situation with , .
  4. Question 4General Aptitudemcq1 mark
    The values of Stock A and Stock B on a particular day are Rs. 50 and Rs. 80, respectively. An investor invests Rs. 100 in Stock A and Rs. 80 in Stock B. He sells all the stocks the next day when the value of Stock A is Rs. 55 and Stock B is Rs. 70. The profit made by the investor is Rs. ________
    • A.
      0
      ✓
    • B.
      5
    • C.
      10
    • D.
      20

    Answer: A

    Solution

    Answer: (A) Stock A: Rs.100 buys shares; next day worth → gain Rs.10. Stock B: Rs.80 buys share; next day worth → loss Rs.10. Net profit .
  5. Question 5General Aptitudemcq1 mark
    'When it is raining, peacocks dance.' Based only on this sentence, which one of the following options is necessarily true?
    • A.
      Peacocks dance only when it is raining.
    • B.
      When peacocks dance, it is raining.
    • C.
      When peacocks are not dancing, it is not raining.
      ✓
    • D.
      When it is not raining, peacocks do not dance.

    Answer: C

    Solution

    Answer: (C) The statement is . The only statement logically equivalent to it is its contrapositive , i.e. 'When peacocks are not dancing, it is not raining.' The other options are its converse or inverse, which need not hold.
  6. Question 6General Aptitudemcq2 marks
    Water : P :: Food : Q Choose the P and Q combination from the options below to form a meaningful analogy.
    • A.
      P = Thirst; Q = Hunger
      ✓
    • B.
      P = Drink; Q = Hunger
    • C.
      P = Thirst; Q = Satiated
    • D.
      P = Wet; Q = Critic

    Answer: A

    Solution

    Answer: (A) Water relieves thirst exactly as food relieves hunger — the relationship 'X relieves Y' is preserved only in option (A).
  7. Question 7General Aptitudemcq2 marks
    Two tiles are missing in Panel I. Which one of the options in Panel II is the appropriate choice for the missing tiles?
    GATE CS 2026 Set 2 Question 7 figure
    • A.
      (i)
      ✓
    • B.
      (ii)
    • C.
      (iii)
    • D.
      (iv)

    Answer: A

    Solution

    Answer: (A) Matching the orientation and shading of the surrounding tiles in Panel I, only the pair of tiles in option (i) completes the pattern consistently.
  8. Question 8General Aptitudemcq2 marks
    Figures (i) and (ii) represent intercity highway systems. The black dots represent cities and the line segments between them represent intercity highways. A salesperson needs to make a trip. She needs to start from a city, visit each of the remaining cities exactly once, and finally return to the same city from which she started. Which one of the following options is then true?
    GATE CS 2026 Set 2 Question 8 figure
    • A.
      Such a trip is possible for (i), but not for (ii).
      ✓
    • B.
      Such a trip is possible for (ii), but not for (i).
    • C.
      Such a trip is possible for both (i) and (ii).
    • D.
      Such a trip is possible neither for (i) nor for (ii).

    Answer: A

    Solution

    Answer: (A) The required trip is a Hamiltonian cycle. The grid graph (i) is bipartite with an equal number of cells in each colour class, and a Hamiltonian cycle can be traced through it. Graph (ii) has a vertex/edge arrangement that forces a repeated or skipped city, so no such closed tour exists. Hence the trip is possible for (i) but not (ii).
  9. Question 9General Aptitudemcq2 marks
    The figure in Panel I below is a grid of cells with four rows and four columns. The numbers on the top and on the left represent the number of cells that are to be shaded in that column and row, respectively. Which one of the options shown in Panel II below represents the grid shaded correctly?
    GATE CS 2026 Set 2 Question 9 figure
    • A.
      (i)
    • B.
      (ii)
      ✓
    • C.
      (iii)
    • D.
      (iv)

    Answer: B

    Solution

    Answer: (B) Only grid (ii) simultaneously satisfies every row total (left margin) and every column total (top margin) given in Panel I; each of the other grids violates at least one row or column count.
  10. Question 10General Aptitudemcq2 marks
    An unbiased six-faced dice whose faces are marked with numbers 1, 2, 3, 4, 5, and 6 is rolled twice in succession and the number on the top face is recorded each time. The probability that the sum of the two recorded numbers is a prime number is ________
    • A.
    • B.
    • C.
      ✓
    • D.

    Answer: C

    Solution

    Answer: (C) Out of equally likely outcomes, the sums that are prime are with counts respectively:
  11. Question 11Discrete Mathematicsmcq1 mark
    For two different persons and , the predicate denotes that knows . Consider the following statement. There is a person who does not know anyone else, but that person is known by everyone else. Which one of the following expressions represents the above statement?
    • A.
      ✓
    • B.
    • C.
    • D.

    Answer: A

    Solution

    Answer: (A) We need one special person (so ) such that for every other person (so ): knows () but does not know (). This is exactly option (A).
  12. Question 12Programming & Data Structuresmcq1 mark
    The set represents various traversals over a binary tree. The set represents the order of visiting nodes during a traversal.
    T                 S
    I:   Inorder      L: left subtree, node, right subtree
    II:  Preorder     M: node, left subtree, right subtree
    III: Postorder    N: left subtree, right subtree, node
    Which one of the following is the correct match from to ?
    • A.
      I – L, II – M, III – N
      ✓
    • B.
      I – M, II – L, III – N
    • C.
      I – N, II – M, III – L
    • D.
      I – L, II – N, III – M

    Answer: A

    Solution

    Answer: (A) Inorder visits left-node-right ; Preorder visits node-left-right ; Postorder visits left-right-node . Hence I–L, II–M, III–N.
  13. Question 13Theory of Computationmcq1 mark
    Which one of the following statements is equivalent to the following assertion? Turing machine decides the language
    • A.
      Turing machine halts on all input strings in
    • B.
      Turing machine accepts all input strings in
    • C.
      Turing machine rejects all input strings in
    • D.
      Turing machine accepts all input strings in and rejects all input strings in
      ✓

    Answer: D

    Solution

    Answer: (D) A TM decides iff it is a total machine that halts on every input, accepting exactly the strings in and rejecting exactly the strings not in . Only option (D) captures both the accept and the reject requirement (and thus halting on all inputs).
  14. Question 14Engineering Mathematicsmcq1 mark
    The probability density function of a random variable which takes real values is
    Which one of the following statements is correct about the random variable ?
    • A.
      is an exponential random variable
    • B.
      is a normal random variable
      ✓
    • C.
      is a Poisson random variable
    • D.
      is a uniform random variable

    Answer: B

    Solution

    Answer: (B) Comparing with gives (since ) and mean . So — a normal random variable.
  15. Question 15Databasesmcq1 mark
    In the context of DBMS, consider the two sets and given below.
    T                     S
    I:   Logical schema   L: Views
    II:  Physical schema  M: File organization and indexes
    III: External schema  N: Relations
    Which one of the following is the correct match from to ?
    • A.
      I – L, II – M, III – N
    • B.
      I – M, II – L, III – N
    • C.
      I – N, II – M, III – L
      ✓
    • D.
      I – N, II – L, III – M

    Answer: C

    Solution

    Answer: (C) In the three-level (ANSI/SPARC) architecture: the logical/conceptual schema describes the relations (); the physical schema describes file organization and indexes (); the external schema describes user views (). Hence I–N, II–M, III–L.
  16. Question 16Digital Logicmcq1 mark
    Which one of the following options is not a property of Boolean Algebra? Note: is OR operation, is AND operation, and is NOT operation.
    • A.
    • B.
      ✓
    • C.
    • D.

    Answer: B

    Solution

    Answer: (B) The complement law states (not ) and . So is false; the others (commutativity and ) are valid.
  17. Question 17Programming & Data Structuresmcq1 mark
    In C runtime environment, which one of the following is stored in heap?
    • A.
      A static variable declared inside a function
    • B.
      An array of integers declared inside a function
    • C.
      A dynamically allocated array of integers created using malloc() function call
      ✓
    • D.
      Return address of a function

    Answer: C

    Solution

    Answer: (C) Static variables live in the static/data segment; local (automatic) arrays and the return address live on the stack. Only memory obtained via malloc() is allocated on the heap.
  18. Question 18Computer Organization & Architecturemcq1 mark
    Consider the following two statements about interrupt handling mechanisms in a CPU. S1: In non-vectored interrupt mechanism, it usually takes more time to start the Interrupt Service Routine (ISR) when compared to that in a vectored interrupt mechanism. S2: In daisy-chain interrupt mechanism, the CPU polls all the input devices individually to determine the source of the interrupt. Which one of the following options is correct with respect to S1 and S2?
    • A.
      Both S1 and S2 are true
    • B.
      Both S1 and S2 are false
    • C.
      S1 is true and S2 is false
      ✓
    • D.
      S1 is false and S2 is true

    Answer: C

    Solution

    Answer: (C) S1 is true: a non-vectored interrupt must supply/compute the ISR address, which takes longer than a vectored interrupt that carries the address. S2 is false: daisy chaining resolves priority in hardware by passing an acknowledge signal down the chain — the CPU does not poll each device individually (that is software polling). Hence S1 true, S2 false.
  19. Question 19Programming & Data Structuresmcq1 mark
    Consider the following three ANSI-C programs, P1, P2, and P3.
    c
    // P1 #include <stdio.h> int a=5; int main(){ int a=7; return(0); } // P2 #include <stdio.h> int main(){ int a=5; int a=7; return(0); } // P3 #include <stdio.h> int main(){ int a=5; float a=7; return(0); }
    Which one of the following statements is true?
    • A.
      Only P1 will compile without any error
      ✓
    • B.
      Only P2 will compile without any error
    • C.
      Only P3 will compile without any error
    • D.
      All three programs P1, P2, and P3 will compile without any error

    Answer: A

    Solution

    Answer: (A) In P1 the local int a simply shadows the global a — legal. In P2 and P3 the identifier a is redeclared in the same scope (as int/int and int/float), which is a compile-time error. Hence only P1 compiles.
  20. Question 20Databasesmcq1 mark
    Consider concurrent execution of two transactions and in a DBMS, both of which access a data object . For these two transactions to not conflict on , which one of the following statements must be true?
    • A.
      Both and only read
      ✓
    • B.
      reads and writes
    • C.
      writes and reads
    • D.
      Both and write

    Answer: A

    Solution

    Answer: (A) Two operations on the same object conflict if at least one of them is a write (read-write, write-read, write-write all conflict). They do not conflict only when both are reads.
  21. Question 21Computer Networksmcq1 mark
    Consider a file of size 4 million bytes being transferred between two hosts connected via a path consisting of three consecutive links of bandwidth 2 Mbps, 500 kbps, and 1 Mbps, respectively. All processing delays and propagation delays are negligible. Assume that there is no other background traffic over the path and no other additional overhead to transfer the file. Which one of the following is the total time (in seconds) to transfer the file? Note: , .
    • A.
      731
    • B.
      64
      ✓
    • C.
      8
    • D.
      16

    Answer: B

    Solution

    Answer: (B) With store-and-forward over serial links, the sustained rate is set by the bottleneck link bps. File bytes bits.
    (The slightly higher pipeline fill at the faster links is negligible for this large file.)
  22. Question 22Computer Networksmcq1 mark
    Which one of the following protocols may need to broadcast some of its messages?
    • A.
      SMTP
    • B.
      FTP
    • C.
      DHCP
      ✓
    • D.
      HTTP

    Answer: C

    Solution

    Answer: (C) A client that has no IP address yet uses DHCP and sends a DHCPDISCOVER as a broadcast () to locate a server. SMTP, FTP and HTTP are unicast, connection-oriented application protocols.
  23. Question 23Operating Systemsmcq1 mark
    Which one of the following CPU scheduling algorithms cannot be preemptive?
    • A.
      Shortest Remaining Time First (SRTF) Scheduling
    • B.
      First Come First Serve (FCFS) Scheduling
      ✓
    • C.
      Round Robin Scheduling
    • D.
      Priority Scheduling

    Answer: B

    Solution

    Answer: (B) FCFS runs each process to completion in arrival order and has no mechanism to preempt the running process. SRTF is the preemptive form of SJF, Round Robin is inherently preemptive (time quantum), and Priority scheduling has a preemptive variant.
  24. Question 24Algorithmsmcq1 mark
    Consider the following functions, where is a positive integer.
    Which one of the following options lists the functions in increasing order of asymptotic growth rate? Note: Assume the base of log to be 2.
    • A.
      ✓
    • B.
    • C.
    • D.

    Answer: A

    Solution

    Answer: (A) With base-2 logs, and . Ordering by growth:
    This is option (A).
  25. Question 25Algorithmsmsq1 mark
    Which of the following can be recurrence relation(s) corresponding to an algorithm with time complexity ?
    • A.
      ✓
    • B.
      ✓
    • C.
    • D.

    Answer: A, B

    Solution

    Answer: (A), (B) (A) . ✓ (B) : by Master theorem dominates . ✓ (C) . ✗ (D) . ✗
  26. Question 26Discrete Mathematicsmsq1 mark
    Let be a binary relation on the set , where if the product of and is the square of an integer. Which of the following properties is/are satisfied by ?
    • A.
      Reflexive
      ✓
    • B.
      Symmetric
      ✓
    • C.
      Transitive
      ✓
    • D.
      Antisymmetric

    Answer: A, B, C

    Solution

    Answer: (A), (B), (C) is a perfect square. - Reflexive: is a square. ✓ - Symmetric: . ✓ - Transitive: if and are squares then is a square, so is a square. ✓ - Antisymmetric: and are both in with , so not antisymmetric. ✗
  27. Question 27Engineering Mathematicsmsq1 mark
    For a real number , let . Which of the following statements is/are true?
    • A.
      The value of is independent of the value of
      ✓
    • B.
      The value of can vary with the value of
    • C.
      There exists such that is a positive real number
      ✓
    • D.
      There exists such that is a negative real number

    Answer: A, C

    Solution

    Answer: (A), (C) The term is odd, so it integrates to over the symmetric interval :
    Thus for every — independent of (A) and always positive (C). It never varies and is never negative.
  28. Question 28Computer Organization & Architecturemsq1 mark
    In a system, numbers are represented using 4-bit two's complement form. Consider four numbers , , and in the system. Which of the following operations will result in arithmetic overflow?
    • A.
    • B.
      ✓
    • C.
    • D.
      ✓

    Answer: B, D

    Solution

    Answer: (B), (D) Values: (range ). - → in range, no overflow. - → overflow ✓ - → in range. - → overflow ✓
  29. Question 29Compiler Designmsq1 mark
    Which of the following grammars is/are ambiguous?
    • A.
    • B.
      ✓
    • C.
      ✓
    • D.

    Answer: B, C

    Solution

    Answer: (B), (C) - (A) generates with a unique derivation — unambiguous. - (B) the classic expression grammar has two parse trees for — ambiguous ✓ - (C) generates but a string like has multiple leftmost derivations (via then , or then ) — ambiguous ✓ - (D) right-linear, unique derivation for each — unambiguous.
  30. Question 30Programming & Data Structuresnat1 mark
    The keys 5, 28, 19, 15, 26, 33, 12, 17, 10 are inserted into a hash table using the hash function . The collisions are resolved by chaining. After all the keys are inserted, the length of the longest chain is __________. (answer in integer)

    Answer: 3

    Solution

    Slots (): . Chains: slot 1 = (length 3), slot 6 = , slot 8 = . Longest chain length .
  31. Question 31Engineering Mathematicsnat1 mark
    Consider the system of linear equations given below.
    Suppose the values of and are chosen such that the system of linear equations produces multiple solutions. Then the product of and is __________. (answer in integer)

    Answer: 24

    Solution

    Infinitely many solutions require the two equations to be proportional:
    From : . Then . In both cases .
  32. Question 32Algorithmsnat1 mark
    Consider an array . Suppose the merge sort algorithm is executed on array to sort it in increasing order. The merge sort algorithm will carry out a total of 7 merge operations. A merge operation on sorted left array and sorted right array is said to be void if the output of the merge operation is the elements of array followed by the elements of array . The number of void merge operations among these 7 merge operations is __________. (answer in integer)

    Answer: 3

    Solution

    A merge is void when . The 7 merges are: merge(10,7)→no; merge(8,19)→void; merge([7,10],[8,19])→no (10>8); merge(41,35)→no; merge(25,31)→void; merge([35,41],[25,31])→no; final merge([7,8,10,19],[25,31,35,41])→void (19≤25). Void merges .
  33. Question 33Computer Networksnat1 mark
    If an IP network uses a subnet mask of 255.255.240.0, the maximum number of IP addresses that can be assigned to network interfaces is __________. (answer in integer)

    Answer: 4094

    Solution

    Mask : the last leaves host bits. Total addresses ; excluding the network and broadcast addresses, assignable addresses .
  34. Question 34Computer Organization & Architecturenat1 mark
    The 32-bit IEEE 754 single precision representation of a number is 0xC2710000. The number in decimal representation is ________. (rounded off to two decimal places)

    Answer: -60.25

    Solution

    . Sign (negative); exponent , so ; mantissa . Value .
  35. Question 35Compiler Designnat1 mark
    A lexical analyzer uses the following token definitions
    letter -> [A-Za-z]
    digit  -> [0-9]
    id     -> letter (letter | digit)*
    number -> digit+
    ws     -> (blank | tab | newline)+
    For the string given below,
    x1   23mm  78   y   7z   zz5   14A  8H  AaYcD
    the number of tokens (excluding ) that will be produced by the lexical analyzer is __________. (answer in integer)

    Answer: 13

    Solution

    An id must start with a letter; a number is a run of digits. Scanning (maximal munch): x1→id(1); 23mm→23+mm(2); 78→number(1); y→id(1); 7z→7+z(2); zz5→id(1); 14A→14+A(2); 8H→8+H(2); AaYcD→id(1). Total .
  36. Question 36Algorithmsmcq2 marks
    Consider a complete graph with vertices (). Note that multiple spanning trees can be constructed over . Each of these spanning trees is represented as a set of edges. The Jaccard coefficient between any two sets is defined as the ratio of the size of the intersection of the two sets to the size of the union of the two sets. Which one of the following options gives the lowest possible value for the Jaccard coefficient between any two spanning trees of ?
    • A.
    • B.
    • C.
      ✓
    • D.

    Answer: C

    Solution

    Answer: (C) Each spanning tree of has edges, and has edges. For , , so two edge-disjoint spanning trees exist. Their intersection is empty, giving a Jaccard coefficient of .
  37. Question 37Algorithmsmcq2 marks
    Let be a weighted directed acyclic graph with edges and vertices. Given and a source vertex in , which one of the following options gives the worst case time complexity of the fastest algorithm to find the lengths of shortest paths from to all vertices that are reachable from in ?
    • A.
      ✓
    • B.
    • C.
    • D.

    Answer: A

    Solution

    Answer: (A) On a DAG, relaxing edges in topological order computes all single-source shortest paths in one linear pass. Topological sort plus the relaxations are both , so the fastest algorithm runs in (Dijkstra/Bellman-Ford are not needed).
  38. Question 38Algorithmsmcq2 marks
    Consider an array of integers of size . The indices of run from 1 to . An algorithm is to be designed to check whether satisfies the condition given below.
    Which one of the following gives the worst case time complexity of the fastest algorithm that can be designed for the problem?
    • A.
      ✓
    • B.
    • C.
    • D.

    Answer: A

    Solution

    Answer: (A) Let be the consecutive differences. The condition says the sequence is strictly increasing. This can be verified by a single linear scan comparing each with , i.e. in .
  39. Question 39Algorithmsmcq2 marks
    Consider a table , where the elements , , represent the cost of the optimal solutions of different subproblems. The recursive formulation is:
    All are initialized to 1. Consider the two algorithms below.
    Algorithm B1:
      For i = 1,2,...,n
        For j = 1,2,...,n
          T[i][j] = 2*T[i-1][j] + 3*T[i][j-1]
    
    Algorithm B2:
      For s = 2,3,...,2n
        For i = 1,2,...,n
          For j = 1,2,...,n
            If (i+j == s)
              T[i][j] = 2*T[i-1][j] + 3*T[i][j-1]
    is correct iff it computes the correct for all . Which one of the following statements is true?
    • A.
      Both algorithms and are correct
      ✓
    • B.
      Algorithm is correct, but algorithm is incorrect
    • C.
      Algorithm is correct, but algorithm is incorrect
    • D.
      Both algorithms and are incorrect

    Answer: A

    Solution

    Answer: (A) Each depends only on and (both have smaller index-sum ). - B1 (row-major): when computing , was done in the previous row and earlier in the same row. ✓ - B2 (by diagonals ): both dependencies have sum , computed in earlier diagonals. ✓ Both are correct.
  40. Question 40Digital Logicmcq2 marks
    Consider the following 4-variable Boolean function
    Consider as MSB, as LSB. Which one of the following options represents the minimal sum of products form for the above function? Note: is OR, is AND, is NOT.
    • A.
    • B.
      ✓
    • C.
    • D.

    Answer: B

    Solution

    Answer: (B) The listed minterms are exactly those with : for , (), and for , (). All eight cells with are set and no others, so the function minimizes to .
  41. Question 41Compiler Designmcq2 marks
    Consider the canonical parsing of the grammar below using terminals and non-terminals with as the start symbol.
    Which one of the following options gives the number of shift-reduce conflicts that will occur in the ACTION table?
    • A.
      2
    • B.
      3
    • C.
      4
    • D.
      5
      ✓

    Answer: D

    Solution

    Answer: (D) The -productions and force reductions in the same states where terminals , (and the following symbols) can be shifted, and adds a shift/reduce clash on . Building the canonical automaton and inspecting each state with a complete item against shiftable terminals yields 5 shift-reduce conflicts in total.
  42. Question 42Databasesmcq2 marks
    In the context of schema normalization, consider a set of functional dependencies whose closure is computed using Armstrong's Axioms: Reflexivity: if then ; Augmentation: if then ; Transitivity: if and then . The Union rule is: if and then . It can be proved that Union is implied by the three axioms. Which one of the following combinations is both necessary and sufficient for the proof?
    • A.
      Reflexivity, Augmentation, and Transitivity
    • B.
      Reflexivity and Augmentation
    • C.
      Transitivity
    • D.
      Augmentation and Transitivity
      ✓

    Answer: D

    Solution

    Answer: (D) Proof of Union from , : 1. , i.e. (Augmentation). 2. (Augmentation). 3. and (Transitivity). Only Augmentation and Transitivity are used — Reflexivity is not needed — so (D) is necessary and sufficient.
  43. Question 43Computer Networksmcq2 marks
    Consider the transmission of data bits 110001011 over a link that uses Cyclic Redundancy Check (CRC) code for error detection. If the generator bit pattern is given to be 1001, which one of the following options shows the remainder bit pattern appended to the data bits before transmission?
    • A.
      011
    • B.
      101
    • C.
      000
    • D.
      100
      ✓

    Answer: D

    Solution

    Answer: (D) The generator has degree 3, so append three 0s: , and divide (mod-2) by . Carrying out the XOR long division leaves the 3-bit remainder , which is appended before transmission.
  44. Question 44Computer Organization & Architecturemcq2 marks
    Consider a processor that has 16 general purpose registers and it uses a 2-byte instruction format for all its instructions. Variable-sized opcodes are permitted. There are three types of instructions; M-type, R-type, and C-type. Each M-type has 2 register operands and a 6-bit immediate operand. Each R-type has 3 register operands. Each C-type has a register operand and a 6-bit offset value. If there are 2 unique M-type opcodes and 7 unique R-type opcodes, which one of the following options gives the maximum number of unique opcodes possible for C-type instructions?
    • A.
      8
    • B.
      4
      ✓
    • C.
      64
    • D.
      16

    Answer: B

    Solution

    Answer: (B) 16 registers → 4 bits/register; total instruction = 16 bits. - M-type operands bits → opcode field bits (4 codes). Using 2 leaves free 2-bit prefixes. - R-type operands bits → opcode bits. Each free 2-bit prefix expands into four-bit codes, so R-codes available; using 7 leaves 1 four-bit code. - C-type operands bits → opcode bits. The 1 remaining four-bit code expands into six-bit C-type opcodes.
  45. Question 45Compiler Designmcq2 marks
    Consider the control flow graph given below. Which one of the following options is the set of live variables at the exit point of each basic block?
    GATE CS 2026 Set 2 Question 45 figure
    • A.
      B1:{a, b, c, e, f}, B2:{d, e}, B3:{b, c, e, f}, B4:
      ✓
    • B.
      B1:, B2:{d, e}, B3:{a, c, f}, B4:
    • C.
      B1:{a, b, c, e, f}, B2:{d, e}, B3:{c, e, f}, B4:
    • D.
      B1:, B2:{d, e, f}, B3:{a, b, c, e, f}, B4:

    Answer: A

    Solution

    Answer: (A) Working backwards (a variable is live at a point if it is used later before being redefined): - At B4 exit (program end): . - B3 () loops back to B1, which uses ; is used in B2/B4 and again in B3 — live out of B3 . - B2 () flows to B4 which uses — live out . - B1 () reaches B2 and B3 which together use — live out . This matches option (A).
  46. Question 46Databasesmcq2 marks
    An index in a DBMS is said to be dense if an index entry appears for every search-key value in the indexed file. Otherwise it is called a sparse index. Consider the following two statements. S1: A hash index must be a dense index S2: A tree index can be a sparse index Which one of the following options is correct?
    • A.
      Both S1 and S2 are true
      ✓
    • B.
      Both S1 and S2 are false
    • C.
      S1 is true and S2 is false
    • D.
      S1 is false and S2 is true

    Answer: A

    Solution

    Answer: (A) S1 is true: a hash index computes a bucket from a search-key value, so it must have an entry for every search-key value present — it cannot be sparse. S2 is true: on a file clustered/sorted on the search key, a tree can store one entry per block (a sparse index). Hence both are true.
  47. Question 47Theory of Computationmsq2 marks
    Consider the following two finite automata and . Which of the following statements is/are true?
    GATE CS 2026 Set 2 Question 47 figure
    • A.
    • B.
      is a proper subset of
    • C.
      ✓
    • D.
      consists of all strings in whose length is divisible by 3
      ✓

    Answer: C, D

    Solution

    Answer: (C), (D) Tracing both automata: and are different languages (so (A) is false) and neither is contained in the other (so (B) is false). Both accept only the empty string in common, so — (C) true. Every non-empty accepted string of either machine has length a multiple of 3, and closing under concatenation yields exactly all strings of length divisible by 3 — (D) true.
  48. Question 48Theory of Computationmsq2 marks
    Let and let . Which of the following constraints ensure(s) that the language is context-free?
    • A.
      ✓
    • B.
      and
    • C.
      and
      ✓
    • D.
      ✓

    Answer: A, C, D

    Solution

    Answer: (A), (C), (D) - (A) : a single balance condition — can be checked with one stack counter. CF ✓ - (B) and : two independent, interleaved comparisons ( and ) — needs two stacks. Not CF ✗ - (C) and : nested matching — a single stack suffices. CF ✓ - (D) : one balance condition. CF ✓
  49. Question 49Programming & Data Structuresmsq2 marks
    Consider a binary search tree (BST) with leaf nodes (); all keys are distinct reals. For a node , is its inorder successor ( if none), and if then . For every leaf node with a non-NULL , a new key with is inserted into the BST. Let be the list of all such new keys. Which of the following statements is/are true?
    • A.
      cannot have any duplicates
      ✓
    • B.
      will have at least one element
    • C.
      After inserting all keys from , the height of the BST can increase at most by one
      ✓
    • D.
      Number of nodes in the BST will double after inserting all keys from

    Answer: A, C

    Solution

    Answer: (A), (C) - (A) Each lies in the disjoint open interval ; these intervals are pairwise disjoint, so all are distinct. True ✓ - (B) If the tree is a single node (a leaf with no successor), is empty. False ✗ - (C) Each is inserted just after an existing leaf/successor, adding at most one new level, so overall height grows by at most 1. True ✓ - (D) (total nodes), so the count does not double. False ✗
  50. Question 50Programming & Data Structuresmsq2 marks
    Consider a stack and a queue , both initially empty with capacity ten. The elements 1,2,3,4,5 arrive one by one in that order; each is assigned to (pushed) or (enqueued). After all five are stored, output is generated by first popping all of , then dequeueing all of . The output obtained is . Given the output, predict whether each element went to or . Which of the following is/are possible valid assignment(s)? Note: means was assigned to and means was assigned to .
    • A.
      ✓
    • B.
      ✓
    • C.
    • D.

    Answer: A, B

    Solution

    Answer: (A), (B) Popping gives the reverse of its push order; dequeuing gives its arrival order. Output (reverse of ) then (). - (A) pop ; → ✓ - (B) pop ; → ✓ - (C) ✗ - (D) ✗
  51. Question 51Operating Systemsmsq2 marks
    Consider three processes P1, P2, P3 running identical code. and are binary semaphores initialized to 1 and 0; is a shared variable initialized to 0. Each line executes atomically.
    Wait(A);
    Print(*);
    X = X+1;
    If (X == 2) {
       Print($);
       Signal(B);
    }
    Signal(A);
    Wait(B);
    Print(#);
    Signal(B);
    Any process may start first and context switches may occur at any time. Which of the following patterns is/are possible outcomes?
    • A.
      **$*###
      ✓
    • B.
      **$#*##
      ✓
    • C.
      **$##*#
      ✓
    • D.
      ***$###

    Answer: A, B, C

    Solution

    Answer: (A), (B), (C) Semaphore serializes the Print(*); X=X+1 section, so the three * are printed one at a time. The second process to enter the section makes and prints $ immediately after its * (and Signal(B)), so the output always begins with **$. The remaining * (third process) and the three # (released one-by-one by ) can interleave in several ways — options (A), (B), (C) are all realizable. Option (D) ***$### needs all three * before $, impossible since $ is printed right after the second *.
  52. Question 52Computer Organization & Architecturemsq2 marks
    Consider a system with a processor and a 4 KB direct mapped cache with block size of 16 bytes. The system has 16 MB physical memory. Four words P, Q, R, S are accessed in the order P, Q, R, S repeated 10 times (40 references total). The cache is initially empty (1 word = 1 byte). Addresses: P: 0x845B32, Q: 0x845B26, R: 0x845B36, S: 0x846B32. Which of the following statements is/are true? Note: , .
    • A.
      Every access to P results in a cache miss
      ✓
    • B.
      Every access to R results in a cache hit
      ✓
    • C.
      Every access to Q results in a cache miss
    • D.
      Except the first access to S, all subsequent accesses to S result in cache hits

    Answer: A, B

    Solution

    Answer: (A), (B) Cache: 4 KB / 16 B lines → 8 index bits; block offset bits. So bits select the line. Lower bits of the addresses: P, R → same block (), so R loads P's block. S differs only above the index/offset region but maps to the same line as P/R, evicting them. Each round P and S map to the same line and keep evicting each other, so every P is a miss (A ✓). R shares P's block and, within a round, is fetched right after P with no intervening eviction, so R is always a hit (B ✓). Q maps to a different line and, after the first round, hits (so (C) 'every Q is a miss' is false). S collides with P/R and is evicted before its next use, so S is not always a hit (D false).
  53. Question 53Operating Systemsnat2 marks
    To keep track of free blocks in a file system, the linked list approach is used. Assume the disk size is 16 GB, block size is 2 KB, and block numbers are 32-bit long. A single pointer of size 4 bytes is used in each block of the list to point to the next block. The number of blocks required to hold the free disk block numbers is __________. (answer in integer) Note: , .

    Answer: 16417

    Solution

    Total disk blocks . Usable space per list block bytes → block numbers per block. Blocks needed .
  54. Question 54Operating Systemsnat2 marks
    A system has a TLB with a reach of 1 MB (the total physical memory reachable through its entries). The paging system uses 4 KB pages. The virtual address space is 64 GB and physical address space is 1 GB. If each TLB entry stores a 4-bit process id, page number, frame number, and a 2-bit control field, then the size of the TLB (in bytes) is __________. (answer in integer) Note: , , .

    Answer: 1536

    Solution

    Number of entries . Page number bits; frame number bits. Entry size bits bytes. TLB size bytes.
  55. Question 55Operating Systemsnat2 marks
    Consider contiguous allocation using a variable partitioning scheme with 8 holes of sizes 20 KB, 4 KB, 25 KB, 18 KB, 7 KB, 9 KB, 15 KB, and 12 KB (no two holes are adjacent). Two processes P1 of size 16 KB and P2 of size 9 KB arrive in that order and are allocated using best-fit. After allocating P1 and P2, the number of holes of size less than 8 KB is __________. (answer in integer) Note: .

    Answer: 3

    Solution

    Best-fit chooses the smallest hole that fits. - P1 (16 KB): smallest hole is 18 KB → leaves a 2 KB hole. - P2 (9 KB): smallest hole is the 9 KB hole → leaves 0 (hole consumed). Resulting holes: 20, 4, 25, 2, 7, 15, 12 KB. Those KB are → .
  56. Question 56Computer Organization & Architecturenat2 marks
    Consider a system with 1 MB physical memory and a word length of 1 byte. The system uses a direct mapped cache, with block numbers starting from 0. The word with physical address 0xA2C28 is mapped to the cache block number . The maximum possible size of the cache (in KB) for this configuration is __________. (answer in integer) Note: , .

    Answer: 128

    Solution

    Physical address (20 bits). If the block size is bytes and the cache has lines, the line index is bits and must equal (8 bits). To maximize cache size , take the index field as the 8 bits immediately above the offset that read ; the largest consistent configuration gives KB. So the maximum cache size KB.
  57. Question 57Computer Organization & Architecturenat2 marks
    A non-pipelined instruction execution unit that operates at 1.6 GHz clock takes an average of 5 clock cycles to complete the execution of an instruction. To improve performance, the system was pipelined aiming at an average throughput of one instruction per clock cycle, but it could operate only at 1.2 GHz due to pipeline overheads. While executing a program, 30% of instructions encountered a stall of 2 cycles due to pipeline hazards. The speed-up obtained by the pipelined design over the non-pipelined one for this program is __________. (rounded off to two decimal places) Note: .

    Answer: 2.3 to 2.4

    Solution

    Non-pipelined time/instruction ns. Pipelined CPI cycles; time/instruction ns. Speed-up .
  58. Question 58Computer Networksnat2 marks
    Consider a new TCP connection. The receiver advertised window is constant at 48 KB, the maximum segment size (MSS) is 2 KB, and the slow start threshold is 16 KB. Assume no timeouts or duplicate acknowledgements. The number of rounds of transmission required for the congestion control algorithm to reach the congestion avoidance phase is __________. (answer in integer) Note: .

    Answer: 4

    Solution

    In slow start, cwnd starts at 1 MSS KB and doubles each round: Round 1: 2 KB, Round 2: 4 KB, Round 3: 8 KB, Round 4: 16 KB. At cwnd KB ssthresh, TCP enters the congestion avoidance phase — after rounds.
  59. Question 59Digital Logicnat2 marks
    Consider the digital circuit shown below with two input lines A and B, two select lines S0 and S1, and an output line Y. The blocks Q and M represent an active-high 2:4 decoder and a 4-to-1 multiplexer, respectively. Out of 16 possible input combinations, the number of combinations that produce is __________. (answer in integer) Note: One input combination is an instance of [A B S1 S0].
    GATE CS 2026 Set 2 Question 59 figure

    Answer: 6

    Solution

    The decoder Q (inputs A,B) drives MUX data inputs , , , , with iff and iff . The select lines pick the data input: - only for → 1 combination. - → 0. - for all → 4 combinations. - only for → 1 combination. Total .
  60. Question 60Programming & Data Structuresnat2 marks
    Consider the following ANSI-C program.
    c
    #include <stdio.h> int main(){ int *ptr, a, b, c; a=5; b=11; c=20; ptr=&a; *ptr=c; ptr=&c; a=*(&b); c=*ptr-a; printf("%d",c); return(0); }
    The output of this program is __________. (answer in integer)

    Answer: 9

    Solution

    ptr=&a; *ptr=c; sets . ptr=&c; now points to . a=*(&b); sets . c=*ptr-a . So the program prints .
  61. Question 61Programming & Data Structuresnat2 marks
    Consider the following ANSI-C function.
    c
    int func(int start, int end){ int length=end+1-start; if((length<1)||(start<0)||(end<0)){ return(0); } if(length%3==0){ return(func(start+1, end)); } else if(length%3==1){ return(1+func(start, end-1)); } else { return(func(start+2, end)); } }
    The maximum possible value that can be returned from this function is __________. (answer in integer)

    Answer: 1

    Solution

    The return value depends only on . Let be the value: - : . - : . - : . - : . Computing: The value never exceeds .
  62. Question 62Engineering Mathematicsnat2 marks
    The determinant of a matrix is 3. The value of the determinant of is __________. (answer in integer)

    Answer: 48

    Solution

    For an matrix, . Here , :
  63. Question 63Engineering Mathematicsnat2 marks
    Suppose an unbiased coin is tossed 6 times, each toss independent. Let be the event that among the second, fourth, and sixth tosses there are at least two heads. Let be the event that among the first, second, third, and fifth tosses there are an equal number of heads and tails. The conditional probability is __________. (rounded off to one decimal place)

    Answer: 0.5

    Solution

    depends on tosses ; of these, only toss 2 is shared with . Given (exactly 2 heads among tosses ), by symmetry , and tosses 4,6 remain fair and independent. So the three relevant tosses are each Heads with probability independently, and
  64. Question 64Engineering Mathematicsnat2 marks
    Consider a function defined as follows. For a real number , if the second digit after the decimal point in is one of the four digits 2, 3, 6 and 7. Otherwise, . The number of points in at which is discontinuous is __________. (answer in integer)

    Answer: 40

    Solution

    is constant on each interval of length determined by the second decimal digit . Within a block where the first digit is fixed, gives values — which change at the boundaries , i.e. 4 jumps per block. Across a first-digit boundary () the value stays — no jump. There are 10 such blocks, giving discontinuities.
  65. Question 65Computer Networksnat2 marks
    It is necessary to design a link-layer protocol between two hosts directly connected over a lossless link of length 3000 kilometers. The link bandwidth is bits per second and the propagation delay is 5 nanoseconds per meter. Every transmitted data byte is assigned a unique sequence number. Let be the minimum number of bits needed for the sequence number field such that (i) the sequence numbers do not wrap around before 60 seconds, and (ii) the maximum utilization of the link is achieved. The value of is ______. (answer in integer)

    Answer: 30

    Solution

    For maximum utilization the link sends continuously at bps for 60 s: bits → bytes . We need distinct sequence numbers for all these bytes: . Since , the minimum is .

Practice the full paper with a timer

Attempt GATE CS 2026 Set 2 in the exact GATE interface and get a detailed score and topic-wise analysis — free.

Create free account →