IAE Academy

PAPERS · GATE CS

GATE CSE 2026 Set 2 question paper with solutions

All 65 questions of the GATE 2026 Set 2 Computer Science and Information Technology paper, in order, with the official answer key from IIT Guwahati. 20 have a full solution.

questions · 100 marks
65questions · 100 marks
with a full solution
20with a full solution
question types
35 MCQ · 11 MSQ · 19 NATquestion types

GATE CSE 2026 Set 2 answer key

Official answers to every question of GATE CSE 2026 Set 2
QuestionTypeMarksAnswer
Q.1MCQ1A
Q.2MCQ1C
Q.3MCQ1A
Q.4MCQ1A
Q.5MCQ1C
Q.6MCQ2A
Q.7MCQ2A
Q.8MCQ2A
Q.9MCQ2B
Q.10MCQ2C
Q.11MCQ1A
Q.12MCQ1A
Q.13MCQ1D
Q.14MCQ1B
Q.15MCQ1C
Q.16MCQ1B
Q.17MCQ1C
Q.18MCQ1C
Q.19MCQ1A
Q.20MCQ1A
Q.21MCQ1B
Q.22MCQ1C
Q.23MCQ1B
Q.24MCQ1A
Q.25MSQ1A, B
Q.26MSQ1A, B, C
Q.27MSQ1A, C
Q.28MSQ1B, D
Q.29MSQ1B, C
Q.30NAT13
Q.31NAT124
Q.32NAT13
Q.33NAT14094
Q.34NAT1-60.25
Q.35NAT113
Q.36MCQ2C
Q.37MCQ2A
Q.38MCQ2A
Q.39MCQ2A
Q.40MCQ2B
Q.41MCQ2D
Q.42MCQ2D
Q.43MCQ2D
Q.44MCQ2B
Q.45MCQ2A
Q.46MCQ2A
Q.47MSQ2C, D
Q.48MSQ2A, C, D
Q.49MSQ2A, C
Q.50MSQ2A, B
Q.51MSQ2A, B, C
Q.52MSQ2A, B
Q.53NAT216417
Q.54NAT21536
Q.55NAT23
Q.56NAT2128
Q.57NAT22.30 to 2.40
Q.58NAT24
Q.59NAT26
Q.60NAT29
Q.61NAT21
Q.62NAT248
Q.63NAT20.5
Q.64NAT240
Q.65NAT230

General Aptitude Q.1 to Q.10

  1. Q.1MCQ · 1 markOfficial answer: A
  2. Q.2MCQ · 1 markOfficial answer: C
  3. Q.3MCQ · 1 markOfficial answer: A
  4. Q.4MCQ · 1 markOfficial answer: A
  5. Q.5MCQ · 1 markOfficial answer: C
  6. Q.6MCQ · 2 marksOfficial answer: A
  7. Q.7MCQ · 2 marksOfficial answer: A
  8. Q.8MCQ · 2 marksOfficial answer: A
  9. Q.9MCQ · 2 marksOfficial answer: B
  10. Q.10MCQ · 2 marksOfficial answer: C

Computer Science and Information Technology Q.11 to Q.65

  1. Q.11MCQ · 1 markOfficial answer: A
  2. Q.12MCQ · 1 markOfficial answer: A

    Data Structures and Algorithms › Trees & heaps

    Each binary tree traversal is defined purely by the relative order in which the node is visited with respect to its left and right subtrees: Inorder = Left, Node, Right; Preorder = Node, Left, Right; Postorder = Left, Right, Node.

    WATCH OUT FOR

    Confusing preorder and postorder — remembering "node visited first" or "node visited last" without anchoring it to the mnemonic (Pre = node before children, Post = node after children), which leads to swapping M and N.

    Full solution
  3. Q.13MCQ · 1 markOfficial answer: D
  4. Q.14MCQ · 1 markOfficial answer: B
  5. Q.15MCQ · 1 markOfficial answer: C
  6. Q.16MCQ · 1 markOfficial answer: B
  7. Q.17MCQ · 1 markOfficial answer: C

    Programming in C › Functions & scope

    A C program's runtime memory layout has four regions: code/text, static/global (data+BSS) segment, stack (activation records: locals, parameters, return addresses), and heap (memory obtained via malloc/calloc/realloc, released only by free or process exit).

    WATCH OUT FOR

    Assuming any "array" or anything that "lives beyond a single line" must be on the heap, or confusing static storage duration with heap allocation — a static local variable is in the data/BSS segment, not the heap, even though it also outlives the function call.

    Full solution
  8. Q.18MCQ · 1 markOfficial answer: C

    Computer Organization and Architecture › I/O, interrupts & DMA

    Vectored interrupts let the interrupting device supply its ISR address/vector directly, so dispatch is fast; non-vectored interrupts force the CPU into extra identification steps before it can jump to the right ISR. Daisy-chaining resolves priority and identifies the interrupting device entirely in hardware (the acknowledge signal is passed serially and intercepted by the requesting device) — it is the alternative to CPU software polling, not an instance of it.

    WATCH OUT FOR

    Confusing daisy-chaining (a hardware priority/identification scheme) with software polling (where the CPU itself queries each device in sequence); the two are often taught back to back and are easy to conflate because both eventually "check devices one by one" — but in daisy-chaining that checking is done by hardware propagation of a signal, not by the CPU executing a polling loop.

    Full solution
  9. Q.19MCQ · 1 markOfficial answer: A

    Programming in C › Functions & scope

    In C, an identifier may be redeclared in a nested (inner) scope to shadow an outer declaration — that is legal — but declaring the same identifier twice within the exact same scope (the same block) is always a compile-time redeclaration error, regardless of whether the types match.

    WATCH OUT FOR

    Treating all three programs as "declaring a twice" as if that phrase alone decides compilability, without checking whether the two declarations sit in the SAME scope (P2, P3 — illegal) or in DIFFERENT, nested scopes (P1 — legal shadowing). Some also mistakenly believe C requires the types to differ (as in P3) before a redeclaration becomes an error, missing that P2's same-type, same-scope redeclaration is equally illegal.

    Full solution
  10. Q.20MCQ · 1 markOfficial answer: A
  11. Q.21MCQ · 1 markOfficial answer: B
  12. Q.22MCQ · 1 markOfficial answer: C
  13. Q.23MCQ · 1 markOfficial answer: B
  14. Q.24MCQ · 1 markOfficial answer: A

    Data Structures and Algorithms › Complexity

    Simplify each function to a standard growth class using and (Stirling), then order the resulting classes: .

    WATCH OUT FOR

    Forgetting that "log" here means log base 2 (as stated in the note) and mis-simplifying ; a common error is to treat as growing faster than (e.g., confusing it with or ), or to assume grows only like rather than by Stirling's approximation.

    Full solution
  15. Q.25MSQ · 1 markOfficial answer: A, B

    Data Structures and Algorithms › Complexity

    Solve each recurrence (by unrolling or the Master theorem) and check which reduce to .

    WATCH OUT FOR

    Applying the Master theorem's Case 1 condition loosely and forgetting that a constant is for any (e.g. ), or confusing Case 1 (branching term dominates) with Case 2 (equal growth, giving an extra factor) — this is exactly what makes option C a distractor for .

    Full solution
  16. Q.26MSQ · 1 markOfficial answer: A, B, C
  17. Q.27MSQ · 1 markOfficial answer: A, C
  18. Q.28MSQ · 1 markOfficial answer: B, D
  19. Q.29MSQ · 1 markOfficial answer: B, C
  20. Q.30NAT · 1 markOfficial answer: 3

    Data Structures and Algorithms › Sorting & hashing

    Compute h(k) = k mod 9 for every key in insertion order, group keys by resulting bucket index (chaining), and report the size of the largest bucket — that size is the "longest chain," not the key values themselves.

    WATCH OUT FOR

    Miscomputing a modulus (e.g., treating 28 mod 9 or 19 mod 9 incorrectly) or forgetting that bucket indices only range 0 to 8 (table size 9), causing keys to be misplaced into the wrong bucket and the chain count to come out wrong.

    Full solution
  21. Q.31NAT · 1 markOfficial answer: 24
  22. Q.32NAT · 1 markOfficial answer: 3

    Data Structures and Algorithms › Sorting & hashing

    In standard top-down merge sort, the array is recursively halved until singletons, then merged back up level by level. A merge of and is "void" exactly when every element of is already every element of — i.e. — so the merged output equals followed by unchanged.

    WATCH OUT FOR

    Assuming a merge is void whenever and are each individually already sorted (true for every leaf-pair merge by definition) rather than checking whether 's elements are ALL less than 's elements; e.g. merge([10],[7]) has two "sorted" singletons but is NOT void since 10 > 7, so the output [7,10] differs from L followed by R = [10,7].

    Full solution
  23. Q.33NAT · 1 markOfficial answer: 4094
  24. Q.34NAT · 1 markOfficial answer: -60.25
  25. Q.35NAT · 1 markOfficial answer: 13
  26. Q.36MCQ · 2 marksOfficial answer: C

    Data Structures and Algorithms › Graph algorithms

    The Jaccard coefficient of two spanning-tree edge sets is minimized (to ) exactly when two edge-disjoint spanning trees of can be found; the maximum number of pairwise edge-disjoint spanning trees packable into is the classical result , which is at least for every .

    WATCH OUT FOR

    Assuming any two spanning trees of must share at least one edge (confusing "distinct" with "edge-disjoint"), or forgetting that the classical spanning-tree-packing bound for is tight (achievable), not just an upper bound — leading test-takers to pick a small nonzero value like instead of .

    Full solution
  27. Q.37MCQ · 2 marksOfficial answer: A

    Data Structures and Algorithms › Graph algorithms

    For a weighted DAG, computing a topological order (Θ(m+n) via DFS or Kahn's algorithm) and then relaxing edges in that order gives correct single-source shortest paths in one linear pass — no priority queue or repeated relaxation is needed, unlike in general graphs.

    WATCH OUT FOR

    Assuming the graph is a general weighted graph (with cycles/negative or arbitrary edges) and reaching for Dijkstra's Θ(m + n log n) (option B) or Bellman-Ford's Θ(nm) (option C), forgetting that acyclicity permits a much faster topological-order relaxation algorithm.

    Full solution
  28. Q.38MCQ · 2 marksOfficial answer: A

    Data Structures and Algorithms › Complexity

    A condition holding for every pair of indices (not just adjacent ones) is a disguised way of saying a derived sequence is strictly monotonic; strict monotonicity only ever needs to be checked between consecutive terms, because strict inequality is transitive.

    WATCH OUT FOR

    Assuming that a condition quantified over ALL pairs requires checking all pairs directly, leading to a wrongly assumed (or, worse, mistaking the transitivity shortcut for something that needs sorting, leading to a wrongly assumed ) — both miss that strict inequality between all pairs collapses to strict monotonicity, which is checkable with one linear pass over consecutive terms.

    Full solution
  29. Q.39MCQ · 2 marksOfficial answer: A

    Data Structures and Algorithms › Design techniques

    Whenever a DP recurrence's dependencies always come from strictly "smaller" cells in some measure (here, strictly decreases by 1 at each dependency), any loop order that is a valid topological order of that dependency structure computes the table correctly — row-major and anti-diagonal ("wavefront") order are both such valid orders here, since each cell's two dependencies fall on the immediately preceding row/column or the immediately preceding diagonal, never on the same diagonal.

    WATCH OUT FOR

    Assuming that scanning order only matters when it visits cells "out of the usual row/column order," and therefore either (a) wrongly flagging as incorrect on the intuition that its triple-nested loop with an if condition looks unusual or wasteful, without checking that its dependencies are actually satisfied, or (b) failing to verify that cells sharing the same diagonal () never depend on each other, which is the fact that makes the inner scan order inside a fixed harmless.

    Full solution
  30. Q.40MCQ · 2 marksOfficial answer: B
  31. Q.41MCQ · 2 marksOfficial answer: D
  32. Q.42MCQ · 2 marksOfficial answer: D
  33. Q.43MCQ · 2 marksOfficial answer: D
  34. Q.44MCQ · 2 marksOfficial answer: B

    Computer Organization and Architecture › Instructions & addressing

    Variable-length opcodes that must be uniquely decodable from a fixed 16-bit instruction behave exactly like a prefix-free (Huffman) code: the set of opcodes, extended to a common comparison depth, must occupy disjoint blocks of a binary code tree (Kraft's inequality). Count how many leaves of that tree the already-fixed M-type and R-type opcodes use up, and the remainder bounds the C-type opcode count.

    WATCH OUT FOR

    Treating each instruction type's leftover opcode bits independently (e.g., concluding C-type has possible opcodes) without imposing the prefix-free condition that lets a single opcode-decoder distinguish M-, R-, and C-type instructions from the same 16-bit word; this ignores that shorter opcodes (M-type, R-type) consume large blocks of the shared code space that longer C-type opcodes cannot then use.

    Full solution
  35. Q.45MCQ · 2 marksOfficial answer: A
  36. Q.46MCQ · 2 marksOfficial answer: A
  37. Q.47MSQ · 2 marksOfficial answer: C, D
  38. Q.48MSQ · 2 marksOfficial answer: A, C, D
  39. Q.49MSQ · 2 marksOfficial answer: A, C

    Data Structures and Algorithms › Trees & heaps

    Every leaf with a non-NULL successor sits at the boundary of a unique, pairwise-disjoint 'gap' in the tree's overall sorted key sequence, and — because a leaf has no right child — the new key for that gap is always forced to attach as that leaf's right child at depth exactly one more than the leaf's own depth.

    WATCH OUT FOR

    Treating Suc(V) as the inorder successor within the leaf sequence only (rather than the successor in the full tree's inorder traversal), or assuming the new key could land anywhere in the tree rather than realizing the 'no right child ⇒ becomes right child of the predecessor' insertion rule forces it to attach directly below its own leaf — both of which make it easy to wrongly reject (A) or (C), or to wrongly accept (B)/(D) without checking the n = 1 / full-tree counterexamples.

    Full solution
  40. Q.50MSQ · 2 marksOfficial answer: A, B

    Data Structures and Algorithms › Linear structures

    A push-then-pop-all sequence of the increasing arrival order 1..5 must come out strictly decreasing (LIFO reverses order), while an enqueue-then-dequeue-all sequence of the same increasing arrivals must come out strictly increasing (FIFO preserves order); so the full output is always a decreasing block (from S) immediately followed by an increasing block (from Q), and checking validity reduces to finding every way to split the printed output into such a decreasing-prefix / increasing-suffix pair.

    WATCH OUT FOR

    Trying to verify each option only by re-simulating it forward (push/pop, enqueue/dequeue) one at a time, which is correct but slow and error-prone under time pressure; the faster and more reliable route is to first characterize the output's required shape (decreasing-then-increasing split of {1,...,5} in arrival order) and then just check where the given output 4 3 1 2 5 can be split that way, which immediately rules out any option whose S-subset, if popped, would not sit at the front in decreasing order matching the given prefix.

    Full solution
  41. Q.51MSQ · 2 marksOfficial answer: A, B, C
  42. Q.52MSQ · 2 marksOfficial answer: A, B

    Computer Organization and Architecture › Memory & cache

    In a direct-mapped cache, split the 24-bit physical address into tag/index/offset. Here offset+index together equal exactly 3 hex digits and tag also equals exactly 3 hex digits, so a 6-hex-digit address splits cleanly as tag = first 3 digits, index = next 2 digits, offset = last digit. Two addresses share a cache block only if BOTH tag and index match; they conflict (evict each other) if only the index matches.

    WATCH OUT FOR

    Assuming S, having a different tag from P/R, must land in a different cache line and never interferes with them — missing that S shares the SAME index (B3) with P and R, which is exactly what causes S to evict, and be evicted by, the P/R block every round. A second common slip is assuming R's very first access must be a miss like P's, overlooking that R is accessed right after P has just loaded that same block within round 1.

    Full solution
  43. Q.53NAT · 2 marksOfficial answer: 16417
  44. Q.54NAT · 2 marksOfficial answer: 1536
  45. Q.55NAT · 2 marksOfficial answer: 3
  46. Q.56NAT · 2 marksOfficial answer: 128

    Computer Organization and Architecture › Memory & cache

    In a direct-mapped cache, the address splits into Tag | Block number ( bits) | Block offset ( bits). Given only the numeric value of the block number (not or individually), find every bit-offset at which an 8-bit window of the physical address equals that block number in binary; here only works. Then, holding fixed, the block-number field can be widened ( increased) for free as long as every newly included higher-order bit is 0, since a leading 0 does not change the field's decimal value — this is what lets the cache be "maximum possible" size rather than a single fixed size.

    WATCH OUT FOR

    Assuming the number of bits in the binary form of the block number (here , 8 bits) directly gives , and stopping there — i.e. computing cache size as instead of recognizing that higher-order zero bits can be folded into a wider block-number field without changing its decimal value, which is what the word "maximum possible" in the question is asking you to exploit.

    Full solution
  47. Q.57NAT · 2 marksOfficial answer: 2.30 to 2.40

    Computer Organization and Architecture › Pipelining

    Speed-up from pipelining = (execution time per instruction, non-pipelined) / (execution time per instruction, pipelined), where execution time per instruction = CPI / clock frequency. The pipelined design's effective CPI must include the extra stall cycles caused by hazards, not just the ideal CPI = 1.

    WATCH OUT FOR

    Forgetting to add the hazard-stall penalty to the pipelined CPI (using CPI = 1 for the pipelined design instead of 1 + 0.3×2 = 1.6), which gives a wrong speed-up of 3.125/(1/1.2) = 2.4 instead of the correct 2.34; or comparing raw clock frequencies (1.6/1.2) instead of execution times per instruction.

    Full solution
  48. Q.58NAT · 2 marksOfficial answer: 4
  49. Q.59NAT · 2 marksOfficial answer: 6
  50. Q.60NAT · 2 marksOfficial answer: 9

    Programming in C › Pointers & arrays

    Track pointer targets and values separately: an assignment through *ptr changes whatever object ptr currently points to, not necessarily the same variable it pointed to earlier or later.

    WATCH OUT FOR

    Assuming *ptr always refers to a throughout the program (since ptr was first set to &a), and missing that ptr=&c; re-targets it to c before the final c=*ptr-a; line — this leads students to wrongly read *ptr as a's value there instead of c's.

    Full solution
  51. Q.61NAT · 2 marksOfficial answer: 1

    Programming in C › Recursion

    Since start never decreases and end never increases, the recursion is driven entirely by length : the transition map is , , , and only the step ever adds +1. Because residue is never a target of any transition, it can occur only once (at the very start, if at all), so at most one point can ever be earned in the whole recursion.

    WATCH OUT FOR

    Assuming the +1 can be earned repeatedly (e.g. once per "cycle" of 3 in the original length) without checking which residues are actually reachable after the first step; tracing only one example instead of proving that residue can never recur rules out any larger value.

    Full solution
  52. Q.62NAT · 2 marksOfficial answer: 48
  53. Q.63NAT · 2 marksOfficial answer: 0.5
  54. Q.64NAT · 2 marksOfficial answer: 40
  55. Q.65NAT · 2 marksOfficial answer: 30