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
| Question | Type | Marks | Answer |
|---|---|---|---|
| Q.1 | MCQ | 1 | A |
| Q.2 | MCQ | 1 | C |
| Q.3 | MCQ | 1 | A |
| Q.4 | MCQ | 1 | A |
| Q.5 | MCQ | 1 | C |
| Q.6 | MCQ | 2 | A |
| Q.7 | MCQ | 2 | A |
| Q.8 | MCQ | 2 | A |
| Q.9 | MCQ | 2 | B |
| Q.10 | MCQ | 2 | C |
| Q.11 | MCQ | 1 | A |
| Q.12 | MCQ | 1 | A |
| Q.13 | MCQ | 1 | D |
| Q.14 | MCQ | 1 | B |
| Q.15 | MCQ | 1 | C |
| Q.16 | MCQ | 1 | B |
| Q.17 | MCQ | 1 | C |
| Q.18 | MCQ | 1 | C |
| Q.19 | MCQ | 1 | A |
| Q.20 | MCQ | 1 | A |
| Q.21 | MCQ | 1 | B |
| Q.22 | MCQ | 1 | C |
| Q.23 | MCQ | 1 | B |
| Q.24 | MCQ | 1 | A |
| Q.25 | MSQ | 1 | A, B |
| Q.26 | MSQ | 1 | A, B, C |
| Q.27 | MSQ | 1 | A, C |
| Q.28 | MSQ | 1 | B, D |
| Q.29 | MSQ | 1 | B, C |
| Q.30 | NAT | 1 | 3 |
| Q.31 | NAT | 1 | 24 |
| Q.32 | NAT | 1 | 3 |
| Q.33 | NAT | 1 | 4094 |
| Q.34 | NAT | 1 | -60.25 |
| Q.35 | NAT | 1 | 13 |
| Q.36 | MCQ | 2 | C |
| Q.37 | MCQ | 2 | A |
| Q.38 | MCQ | 2 | A |
| Q.39 | MCQ | 2 | A |
| Q.40 | MCQ | 2 | B |
| Q.41 | MCQ | 2 | D |
| Q.42 | MCQ | 2 | D |
| Q.43 | MCQ | 2 | D |
| Q.44 | MCQ | 2 | B |
| Q.45 | MCQ | 2 | A |
| Q.46 | MCQ | 2 | A |
| Q.47 | MSQ | 2 | C, D |
| Q.48 | MSQ | 2 | A, C, D |
| Q.49 | MSQ | 2 | A, C |
| Q.50 | MSQ | 2 | A, B |
| Q.51 | MSQ | 2 | A, B, C |
| Q.52 | MSQ | 2 | A, B |
| Q.53 | NAT | 2 | 16417 |
| Q.54 | NAT | 2 | 1536 |
| Q.55 | NAT | 2 | 3 |
| Q.56 | NAT | 2 | 128 |
| Q.57 | NAT | 2 | 2.30 to 2.40 |
| Q.58 | NAT | 2 | 4 |
| Q.59 | NAT | 2 | 6 |
| Q.60 | NAT | 2 | 9 |
| Q.61 | NAT | 2 | 1 |
| Q.62 | NAT | 2 | 48 |
| Q.63 | NAT | 2 | 0.5 |
| Q.64 | NAT | 2 | 40 |
| Q.65 | NAT | 2 | 30 |
General Aptitude Q.1 to Q.10
- Q.1MCQ · 1 markOfficial answer: A
- Q.2MCQ · 1 markOfficial answer: C
- Q.3MCQ · 1 markOfficial answer: A
- Q.4MCQ · 1 markOfficial answer: A
- Q.5MCQ · 1 markOfficial answer: C
- Q.6MCQ · 2 marksOfficial answer: A
- Q.7MCQ · 2 marksOfficial answer: A
- Q.8MCQ · 2 marksOfficial answer: A
- Q.9MCQ · 2 marksOfficial answer: B
- Q.10MCQ · 2 marksOfficial answer: C
Computer Science and Information Technology Q.11 to Q.65
- Q.11MCQ · 1 markOfficial answer: A
- 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 FORFull solutionConfusing 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.
- Q.13MCQ · 1 markOfficial answer: D
- Q.14MCQ · 1 markOfficial answer: B
- Q.15MCQ · 1 markOfficial answer: C
- Q.16MCQ · 1 markOfficial answer: B
- 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 byfreeor process exit).WATCH OUT FORFull solutionAssuming any "array" or anything that "lives beyond a single line" must be on the heap, or confusing
staticstorage duration with heap allocation — astaticlocal variable is in the data/BSS segment, not the heap, even though it also outlives the function call. - 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 FORFull solutionConfusing 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.
- 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 FORFull solutionTreating all three programs as "declaring
atwice" 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. - Q.20MCQ · 1 markOfficial answer: A
- Q.21MCQ · 1 markOfficial answer: B
- Q.22MCQ · 1 markOfficial answer: C
- Q.23MCQ · 1 markOfficial answer: B
- 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 FORFull solutionForgetting 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.
- 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 FORFull solutionApplying 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 .
- Q.26MSQ · 1 markOfficial answer: A, B, C
- Q.27MSQ · 1 markOfficial answer: A, C
- Q.28MSQ · 1 markOfficial answer: B, D
- Q.29MSQ · 1 markOfficial answer: B, C
- 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 FORFull solutionMiscomputing 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.
- Q.31NAT · 1 markOfficial answer: 24
- 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 FORFull solutionAssuming 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].
- Q.33NAT · 1 markOfficial answer: 4094
- Q.34NAT · 1 markOfficial answer: -60.25
- Q.35NAT · 1 markOfficial answer: 13
- 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 FORFull solutionAssuming 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 .
- 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 FORFull solutionAssuming 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.
- 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 FORFull solutionAssuming 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.
- 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 FORFull solutionAssuming 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
ifcondition 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. - Q.40MCQ · 2 marksOfficial answer: B
- Q.41MCQ · 2 marksOfficial answer: D
- Q.42MCQ · 2 marksOfficial answer: D
- Q.43MCQ · 2 marksOfficial answer: D
- 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 FORFull solutionTreating 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.
- Q.45MCQ · 2 marksOfficial answer: A
- Q.46MCQ · 2 marksOfficial answer: A
- Q.47MSQ · 2 marksOfficial answer: C, D
- Q.48MSQ · 2 marksOfficial answer: A, C, D
- 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 FORFull solutionTreating 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.
- 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 FORFull solutionTrying 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.
- Q.51MSQ · 2 marksOfficial answer: A, B, C
- 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 FORFull solutionAssuming 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.
- Q.53NAT · 2 marksOfficial answer: 16417
- Q.54NAT · 2 marksOfficial answer: 1536
- Q.55NAT · 2 marksOfficial answer: 3
- 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 FORFull solutionAssuming 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.
- 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 FORFull solutionForgetting 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.
- Q.58NAT · 2 marksOfficial answer: 4
- Q.59NAT · 2 marksOfficial answer: 6
- Q.60NAT · 2 marksOfficial answer: 9
Programming in C › Pointers & arrays
Track pointer targets and values separately: an assignment through
*ptrchanges whatever objectptrcurrently points to, not necessarily the same variable it pointed to earlier or later.WATCH OUT FORFull solutionAssuming
*ptralways refers toathroughout the program (sinceptrwas first set to&a), and missing thatptr=&c;re-targets it tocbefore the finalc=*ptr-a;line — this leads students to wrongly read*ptrasa's value there instead ofc's. - Q.61NAT · 2 marksOfficial answer: 1
Since
startnever decreases andendnever increases, the recursion is driven entirely bylength: 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 FORFull solutionAssuming the
+1can 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. - Q.62NAT · 2 marksOfficial answer: 48
- Q.63NAT · 2 marksOfficial answer: 0.5
- Q.64NAT · 2 marksOfficial answer: 40
- Q.65NAT · 2 marksOfficial answer: 30