IAE Academy

PAPERS · GATE CS

GATE CSE 2025 Set 2 question paper with solutions

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

questions · 100 marks
65questions · 100 marks
with a full solution
20with a full solution
question types
32 MCQ · 18 MSQ · 15 NATquestion types

GATE CSE 2025 Set 2 answer key

Official answers to every question of GATE CSE 2025 Set 2
QuestionTypeMarksAnswer
Q.1MCQ1C
Q.2MCQ1C
Q.3MCQ1A
Q.4MCQ1A
Q.5MCQ1B
Q.6MCQ2B
Q.7MCQ2B
Q.8MCQ2A
Q.9MCQ2D
Q.10MCQ2C
Q.11MCQ1C
Q.12MCQ1A
Q.13MCQ1B
Q.14MCQ1A
Q.15MCQ1A
Q.16MCQ1B
Q.17MCQ1A
Q.18MCQ1D
Q.19MCQ1D
Q.20MCQ1A
Q.21MCQ1C
Q.22MCQ1C
Q.23MCQ1D
Q.24MCQ1A
Q.25MCQ1D
Q.26MCQ1D
Q.27MSQ1B, C
Q.28MSQ1D
Q.29MSQ1B, C, D
Q.30MSQ1B, C
Q.31MSQ1A, B, C
Q.32NAT113
Q.33NAT121
Q.34NAT1250
Q.35NAT14
Q.36MCQ2A
Q.37MCQ2C
Q.38MCQ2A
Q.39MCQ2A
Q.40MCQ2C
Q.41MCQ2D
Q.42MSQ2B, C
Q.43MSQ2A, D
Q.44MSQ2A, B, C
Q.45MSQ2A
Q.46MSQ2C, D
Q.47MSQ2D
Q.48MSQ2C, D
Q.49MSQ2A, B, C
Q.50MSQ2B, C, D
Q.51MSQ2C, D
Q.52MSQ2A, C
Q.53MSQ2B
Q.54MSQ2A, C, D
Q.55NAT24.0
Q.56NAT2260.20 to 261.20
Q.57NAT233
Q.58NAT211
Q.59NAT26
Q.60NAT26
Q.61NAT23.0
Q.62NAT2111
Q.63NAT246
Q.64NAT20.5
Q.65NAT20.70 to 0.80

General Aptitude Q.1 to Q.10

  1. Q.1MCQ · 1 markOfficial answer: C
  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: B
  6. Q.6MCQ · 2 marksOfficial answer: B
  7. Q.7MCQ · 2 marksOfficial answer: B
  8. Q.8MCQ · 2 marksOfficial answer: A
  9. Q.9MCQ · 2 marksOfficial answer: D
  10. Q.10MCQ · 2 marksOfficial answer: C

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

  1. Q.11MCQ · 1 markOfficial answer: C
  2. Q.12MCQ · 1 markOfficial answer: A
  3. Q.13MCQ · 1 markOfficial answer: B

    Data Structures and Algorithms › Trees & heaps

    In a binary tree where every node has 0 or 2 children (a "full" or "proper" binary tree), counting edges two ways (n-1 total edges vs. 2 edges per 2-child node) gives n2 = (n-1)/2, equivalently the identity n0 = n2 + 1.

    WATCH OUT FOR

    Confusing "full binary tree" (every node has 0 or 2 children — the condition given here) with "complete binary tree" (all levels filled except possibly the last), or misremembering the identity as n0 = n2 (rather than n0 = n2 + 1), which would incorrectly give n2 = n/2, option (C).

    Full solution
  4. Q.14MCQ · 1 markOfficial answer: A
  5. Q.15MCQ · 1 markOfficial answer: A
  6. Q.16MCQ · 1 markOfficial answer: B
  7. Q.17MCQ · 1 markOfficial answer: A
  8. Q.18MCQ · 1 markOfficial answer: D
  9. Q.19MCQ · 1 markOfficial answer: D

    Programming in C › Pointers & arrays

    stringcopy(a, a+2) performs a forward, overlapping left-shift of the string by 2 positions. Because the destination pointer s always trails the source pointer t by exactly 2 (i.e., s is always behind t), each byte is read by t before s ever reaches that same array position to overwrite it — so a forward while(*t) *s++ = *t++; loop is safe here (no data is clobbered before being read). The loop stops the instant *t is the ORIGINAL null terminator, so any bytes beyond where s has reached at that point retain their pre-shift values rather than being copied or zeroed.

    WATCH OUT FOR

    Assuming the loop runs one extra time and copies the null terminator (or copies through index 13), which would wipe out the leftover 'd' and '!' and give "Hello World!" (option B). The loop condition while(*t) is checked BEFORE each assignment, so as soon as t points at the original '\0' (index 14), the loop exits immediately without ever writing to s at that position — leaving a[12] and a[13] (originally 'd' and '!') untouched from before the shift. Another common slip is forgetting these are the original pre-shift values at those two positions, not garbage or copies of something else.

    Full solution
  10. Q.20MCQ · 1 markOfficial answer: A

    Data Structures and Algorithms › Sorting & hashing

    To show an element is not the largest, it is enough to find one element bigger than it: a single comparison between any two elements does that, and the smaller of the two is the answer.

    WATCH OUT FOR

    Confusing this with "find the maximum" (which needs comparisons) or "find the second largest" (needs comparisons via a tournament). The question only asks for ANY element guaranteed not to be the largest, which is a much weaker requirement solvable in a single comparison.

    Full solution
  11. Q.21MCQ · 1 markOfficial answer: C
  12. Q.22MCQ · 1 markOfficial answer: C
  13. Q.23MCQ · 1 markOfficial answer: D
  14. Q.24MCQ · 1 markOfficial answer: A
  15. Q.25MCQ · 1 markOfficial answer: D
  16. Q.26MCQ · 1 markOfficial answer: D
  17. Q.27MSQ · 1 markOfficial answer: B, C
  18. Q.28MSQ · 1 markOfficial answer: D

    Computer Organization and Architecture › Instructions & addressing

    The Instruction Set Architecture (ISA) is the programmer/compiler-visible contract between hardware and software: the instruction set, addressing modes, and the architecturally visible register set (how many registers a program can name and how they're encoded). Everything about how that contract is physically realized — cache size, number of cache levels, clock frequency — is microarchitecture/implementation, and can differ across chips that implement the identical ISA.

    WATCH OUT FOR

    Treating any processor specification listed in a datasheet (clock speed, cache size, cache levels) as part of the "architecture," when ISA specifically means the software-visible contract, not the hardware implementation details that vary between different chips sharing the same ISA.

    Full solution
  19. Q.29MSQ · 1 markOfficial answer: B, C, D

    Data Structures and Algorithms › Graph algorithms

    In an undirected graph, DFS classifies every non-tree edge as a back edge (never forward or cross), and BFS levels correspond exactly to shortest-path distances from the source, so any non-tree edge in a BFS tree can only connect vertices at levels differing by at most 1. Both traversals visit exactly the reachable set from a start vertex, so repeating from each unvisited vertex finds all connected components.

    WATCH OUT FOR

    Assuming forward and cross edges can occur in a DFS of an undirected graph (as they can in a directed graph), which leads students to wrongly mark (B) as false; also confusing a DFS tree (built for reachability, not distance) with a BFS tree when judging shortest-path claims.

    Full solution
  20. Q.30MSQ · 1 markOfficial answer: B, C
  21. Q.31MSQ · 1 markOfficial answer: A, B, C
  22. Q.32NAT · 1 markOfficial answer: 13

    Computer Organization and Architecture › ALU & control unit

    In Booth's algorithm, at each of the cycles the ALU performs add M, subtract M, or nothing, based on the pair (with starting at 0): pair adds M, pair subtracts M, and or do nothing except an arithmetic shift. Because at cycle is just the original bit (shifted in from the previous cycle), the total add/subtract count equals the number of bit-to-bit transitions ( or ) when scanning the multiplier Q from its LSB toward its MSB, with an extra leading prepended — independent of the multiplicand M.

    WATCH OUT FOR

    Assuming the number of add/subtract operations depends on the multiplicand M, or forgetting to prepend the initial bit — omitting it undercounts the transition at and gives instead of .

    Full solution
  23. Q.33NAT · 1 markOfficial answer: 21

    Programming in C › C basics

    This do-while loop is the subtraction-based (slow) Euclidean algorithm: it repeatedly replaces the larger of x, y by their difference until x equals y, at which point both variables hold gcd(x, y).

    WATCH OUT FOR

    Treating it as a while loop and skipping the first pass's guaranteed subtraction, or stopping the trace as soon as x first becomes 21 (after iteration 1) without continuing until x!=y actually turns false — x stays 21 throughout, but y still needs four more iterations to reach 21.

    Full solution
  24. Q.34NAT · 1 markOfficial answer: 250
  25. Q.35NAT · 1 markOfficial answer: 4

    Data Structures and Algorithms › Trees & heaps

    Standard BST insertion: each new key is compared against nodes starting from the root, going left if smaller and right if larger, until an empty spot is found; the depth of a node equals the number of edges on its unique root path.

    WATCH OUT FOR

    Counting the number of nodes on the path (5) instead of the number of edges (4), or inserting 5 relative to 10 instead of continuing the BST search down to -4's subtree (5 must be compared against -4, since 5 < 10 sends it left first).

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

    Data Structures and Algorithms › Graph algorithms

    Every spanning tree of a connected graph on vertices has exactly edges, so adding a constant to every edge shifts every spanning tree's total weight by the SAME fixed amount — this cannot change which tree has minimum weight. But different simple paths between two vertices can use different numbers of edges, so the same shift adds different amounts to different candidate paths, which can flip which path is shortest.

    WATCH OUT FOR

    Assuming that because MSTs are preserved under a uniform additive shift, shortest paths must be too — students forget that different u-v paths can use different numbers of edges, so the shift is NOT applied equally to all candidate paths (unlike spanning trees, which always have exactly n−1 edges regardless of which tree is chosen).

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

    Data Structures and Algorithms › Complexity

    Melding two structures optimally means using each structure's cheapest correct rebuild strategy: pointer splicing for the linked list (Θ(1)), linear-time array concatenation + bottom-up build-heap for the heap (Θ(n), not the Θ(n log n) of repeated insertion), and in-order flatten + merge + balanced rebuild for the BST (Θ(n) total).

    WATCH OUT FOR

    Assuming meld of two heaps costs Θ(n log n) by imagining n repeated insertions into one heap, instead of recognizing that concatenating the arrays and running the linear-time (Floyd's) build-heap procedure achieves Θ(n).

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

    Computer Organization and Architecture › Memory & cache

    In a direct-mapped, byte-addressable cache, the memory address splits into Tag + Index + Block-offset bits. Main memory size = bytes; number of cache lines = ; cache size = (number of lines) × (block size).

    WATCH OUT FOR

    Forgetting that a block-offset field needs bits and wrongly adding an extra offset bit even when block size is 1 byte (offset = 0 bits), or confusing "index bits" with "number of blocks" incorrectly when computing cache size.

    Full solution
  30. Q.40MCQ · 2 marksOfficial answer: C
  31. Q.41MCQ · 2 marksOfficial answer: D

    Data Structures and Algorithms › Sorting & hashing

    A bitonic array can be searched in two binary-search-style stages — first locate the peak (the point where the array switches from ascending to descending), then binary-search whichever monotonic half is needed — giving comparisons; since any comparison-based search over distinct values needs comparisons in the worst case, the tight, best-possible bound is .

    WATCH OUT FOR

    Assuming a bitonic array needs comparisons because it "looks like" you must binary-search twice (once to find the peak, once inside a half) and multiplying the two stages together instead of adding them — the two stages are sequential (add), not nested (multiply), so the total stays , not .

    Full solution
  32. Q.42MSQ · 2 marksOfficial answer: B, C
  33. Q.43MSQ · 2 marksOfficial answer: A, D
  34. Q.44MSQ · 2 marksOfficial answer: A, B, C
  35. Q.45MSQ · 2 marksOfficial answer: A

    Data Structures and Algorithms › Linear structures

    To add O(1) MIN to a stack without touching PUSH/POP's O(1) cost, the extra information must be attachable and readable in O(1) per operation and must never need to be recomputed from scratch on POP. Storing, with each element as it is pushed, a pointer to the minimum of everything below it achieves this because that stored value is fixed forever once written and POP never has to search for a replacement minimum — the newly exposed top already carries it.

    WATCH OUT FOR

    Thinking any structure that can report the minimum in O(1) is good enough, and overlooking that POP must also stay O(1): a single global min pointer (B) answers MIN in O(1) but forces an O(n) rescan on POP when the current minimum is popped, and a sorted array (C) or min-heap (D) cannot be kept updated in O(1) per PUSH/POP even though they can report the minimum quickly.

    Full solution
  36. Q.46MSQ · 2 marksOfficial answer: C, D
  37. Q.47MSQ · 2 marksOfficial answer: D
  38. Q.48MSQ · 2 marksOfficial answer: C, D
  39. Q.49MSQ · 2 marksOfficial answer: A, B, C
  40. Q.50MSQ · 2 marksOfficial answer: B, C, D
  41. Q.51MSQ · 2 marksOfficial answer: C, D
  42. Q.52MSQ · 2 marksOfficial answer: A, C
  43. Q.53MSQ · 2 marksOfficial answer: B
  44. Q.54MSQ · 2 marksOfficial answer: A, C, D
  45. Q.55NAT · 2 marksOfficial answer: 4.0

    Computer Organization and Architecture › Memory & cache

    In a multi-level cache, AMAT is built recursively from the innermost level outward: AMAT = (access time of level ) + (miss rate of level ) × (penalty incurred on a miss at level ), where that miss penalty is itself the access/transfer cost to the next level plus (that level's own miss rate × the penalty of going further down).

    WATCH OUT FOR

    Treating the 10 ns and 100 ns figures as independent, unconditional penalties and simply adding them (e.g., , using the L2 miss rate against the overall access count rather than conditioning it on an L1 miss first), or forgetting that the L2 miss penalty (100 ns) is only incurred on the fraction of accesses that miss in both L1 and L2, not on every L1 miss.

    Full solution
  46. Q.56NAT · 2 marksOfficial answer: 260.20 to 261.20

    Computer Organization and Architecture › Pipelining

    In a synchronous pipeline, the clock cycle time must be long enough for the slowest stage plus the inter-stage latch overhead: . For instructions through a -stage pipeline with no stalls, the total number of cycles is (fill the pipeline in cycles for the first instruction, then one more cycle per remaining instruction).

    WATCH OUT FOR

    A common error is using cycles (as if every instruction needed all cycles independently) instead of the correct pipelined cycle count, or forgetting to add the latch delay to the slowest stage when computing the clock period.

    Full solution
  47. Q.57NAT · 2 marksOfficial answer: 33

    Data Structures and Algorithms › Trees & heaps

    Trace the B+-tree insertion as a cascading split: first split the overflowing leaf (copy up the new right leaf's smallest key), then check whether that insertion overflows the parent and split it too (push up the middle key), and finally identify which of the resulting internal nodes the new leaf actually hangs from — the answer is the smallest key in that node, not in the original parent B.

    WATCH OUT FOR

    Stopping after the leaf split and reporting the value copied up into the (pre-split) parent B — e.g. giving 25, or giving 19 by keeping the leaf attached to the original left-hand side — instead of continuing to split the overflowing internal node B and re-checking which of the two resulting nodes (7,19) or (33,44) the (25*,26*) leaf now belongs to.

    Full solution
  48. Q.58NAT · 2 marksOfficial answer: 11
  49. Q.59NAT · 2 marksOfficial answer: 6

    Data Structures and Algorithms › Graph algorithms

    The double-BFS algorithm (BFS from an arbitrary vertex to find one diameter endpoint, then BFS from that endpoint to find the other) correctly computes the diameter of a tree — a classical, provable result that fails for general graphs but is guaranteed for trees.

    WATCH OUT FOR

    Treating the two hub vertices' branch depths asymmetrically or forgetting to add the connecting P-Q edge itself (giving 5 instead of 6), or missing the T2 branch off R2 and wrongly taking the Q-side depth as only 2 (via B1/B2) instead of 3 (via R2-R3-R4).

    Full solution
  50. Q.60NAT · 2 marksOfficial answer: 6
  51. Q.61NAT · 2 marksOfficial answer: 3.0

    Computer Organization and Architecture › Pipelining

    Total clock cycles = Σ(CPI_i × count_i) for each instruction class; total execution time = total cycles × clock cycle time, so clock cycle time = total execution time / total clock cycles.

    WATCH OUT FOR

    Dividing the given total time (6.3 s) by the given total instruction count (6.4×10^8) to get an "average time per instruction" instead of first computing total clock cycles from the CPI table and dividing time by cycles — this conflates cycles with instructions and ignores the CPI values entirely.

    Full solution
  52. Q.62NAT · 2 marksOfficial answer: 111

    Programming in C › Pointers & arrays

    Partial array initializers zero-fill the remaining elements; pointer arithmetic (&arr[0] + 1) moves by one element's width, not one byte; and *ptr and arr[1] refer to the same memory once ptr points into arr[1], so a change through one is visible through the other.

    WATCH OUT FOR

    Treating a, *ptr, and arr[1] as three independent values once (*ptr)++ fires, instead of recognizing ptr aliases arr[1] at that point (so the increment changes arr[1] itself) — or forgetting that a already captured the old value of 50 before the increment happened, and wrongly using the post-increment value for a too.

    Full solution
  53. Q.63NAT · 2 marksOfficial answer: 46

    Programming in C › Functions & scope

    Trace nested function calls exactly in evaluation order: g(f(n)) first fully evaluates f(n), which itself calls g(n*2), before the outer g is applied to that result.

    WATCH OUT FOR

    Applying g only once per loop iteration (forgetting that f(n) internally already calls g), e.g. computing sum += n*2+10 instead of sum += g(f(n)) = (n*2+10)+10, which gives 36 instead of 46.

    Full solution
  54. Q.64NAT · 2 marksOfficial answer: 0.5
  55. Q.65NAT · 2 marksOfficial answer: 0.70 to 0.80