IAE Academy

PAPERS · GATE CS

GATE CSE 2024 Set 2 question paper with solutions

All 65 questions of the GATE 2024 Set 2 Computer Science and Information Technology paper, in order, with the official answer key from IISc Bengaluru. 16 have a full solution.

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

GATE CSE 2024 Set 2 answer key

Official answers to every question of GATE CSE 2024 Set 2
QuestionTypeMarksAnswer
Q.1MCQ1C
Q.2MCQ1A
Q.3MCQ1A
Q.4MCQ1C
Q.5MCQ1B
Q.6MCQ2C
Q.7MCQ2C
Q.8MCQ2D
Q.9MCQ2A
Q.10MCQ2A
Q.11MCQ1C
Q.12MCQ1A
Q.13MCQ1A
Q.14MCQ1B
Q.15MCQ1A
Q.16MCQ1B
Q.17MCQ1B
Q.18MCQ1B
Q.19MCQ1A
Q.20MCQ1A
Q.21MCQ1B
Q.22MCQ1A
Q.23MSQ1B
Q.24MSQ1B, C, D
Q.25MSQ1A, B
Q.26MSQ1A, B
Q.27MSQ1A, C, D
Q.28MSQ1B, C
Q.29MSQ1B, D
Q.30MSQ1B, C
Q.31MSQ1A
Q.32MSQ1C, D
Q.33MSQ1A, B, D
Q.34NAT15
Q.35NAT13
Q.36MCQ2B
Q.37MCQ2B
Q.38MCQ2A
Q.39MCQ2A
Q.40MCQ2A
Q.41MCQ2B
Q.42MCQ2B
Q.43MCQ2A
Q.44MCQ2D
Q.45MCQ2B
Q.46MSQ2B, C
Q.47MSQ2A, B
Q.48MSQ2B, C, D
Q.49MSQ2A, B, D
Q.50MSQ2C, D
Q.51MSQ2D
Q.52MSQ2B, C
Q.53NAT229.50 to 30.50
Q.54NAT24
Q.55NAT2500
Q.56NAT250
Q.57NAT232
Q.58NAT22.9 to 3.1
Q.59NAT29
Q.60NAT22
Q.61NAT234
Q.62NAT215
Q.63NAT24
Q.64NAT21028
Q.65NAT29

General Aptitude Q.1 to Q.10

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

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

  1. Q.11MCQ · 1 markOfficial answer: C

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

    With cycle stealing, DMA throughput is (cycles stolen per second) × (data moved per cycle). Cycles stolen per second = clock rate × the fraction of cycles given to DMA.

    WATCH OUT FOR

    The usual mistakes are misreading the Indian digit grouping (25,60,000 is 2.56 million and 2,56,000 is 256 thousand) and forgetting to turn bytes into bits. Leaving the answer in bytes gives 3,20,000 bytes/s, which is not an option. Taking 0.1% instead of 1% leads to option (A).

    Full solution
  2. Q.12MCQ · 1 markOfficial answer: A
  3. Q.13MCQ · 1 markOfficial answer: A

    Programming in C › Functions & scope

    Separate two independent things: (1) the order in which argument expressions are evaluated (right to left here, which only affects the order of side-effect printing during the call f(g(10), h(20))), and (2) which value ends up bound to which parameter inside the called function (always by position — the first argument's value goes to the first parameter, regardless of evaluation order).

    WATCH OUT FOR

    Assuming that "right to left evaluation" also means the parameters are somehow bound out of order inside f, e.g. treating y as if it held g(10)'s value because h(20) was evaluated first. Evaluation order only changes when the side effects (the printf calls inside g and h as arguments) happen; it never changes that the first written argument's value goes to the first parameter (x) and the second to the second (y).

    Full solution
  4. Q.14MCQ · 1 markOfficial answer: B
  5. Q.15MCQ · 1 markOfficial answer: A

    Data Structures and Algorithms › Complexity

    A linear homogeneous recurrence with constant coefficients is solved via its characteristic equation; the roots give the exact closed form, and initial conditions pin down the coefficients.

    WATCH OUT FOR

    Assuming the larger root (3) always dominates the asymptotic growth without checking whether its coefficient in the closed form is actually zero — here the initial conditions force the coefficient of to vanish, so the recurrence in fact grows only as , not .

    Full solution
  6. Q.16MCQ · 1 markOfficial answer: B
  7. Q.17MCQ · 1 markOfficial answer: B
  8. Q.18MCQ · 1 markOfficial answer: B
  9. Q.19MCQ · 1 markOfficial answer: A
  10. Q.20MCQ · 1 markOfficial answer: A
  11. Q.21MCQ · 1 markOfficial answer: B
  12. Q.22MCQ · 1 markOfficial answer: A
  13. Q.23MSQ · 1 markOfficial answer: B
  14. Q.24MSQ · 1 markOfficial answer: B, C, D
  15. Q.25MSQ · 1 markOfficial answer: A, B
  16. Q.26MSQ · 1 markOfficial answer: A, B
  17. Q.27MSQ · 1 markOfficial answer: A, C, D
  18. Q.28MSQ · 1 markOfficial answer: B, C
  19. Q.29MSQ · 1 markOfficial answer: B, D
  20. Q.30MSQ · 1 markOfficial answer: B, C
  21. Q.31MSQ · 1 markOfficial answer: A

    Computer Organization and Architecture › Pipelining

    To classify a data hazard between two instructions sharing a register, first tag every access to that register, in program order, as a read (source) or a write (destination): earlier-write/later-read = RAW (true), earlier-read/later-write = WAR (anti), and earlier-write/later-write = WAW (output). Only a register that is genuinely written by BOTH instructions can be WAW, and only one genuinely read-then-written can be WAR — mislabeling one for the other is the entire trap in this question.

    WATCH OUT FOR

    Assuming that because two instructions both "touch" the same register in some order, any of RAW/WAR/WAW could apply interchangeably — e.g. calling the I2(reads R3)→I3(writes R3) pair a RAW dependency (as option C does) instead of correctly recognizing it as WAR, or calling I1(writes R3)→I3(writes R3) a WAR (as option B does) instead of WAW. The fix is to always ask two separate yes/no questions per pair — "does the earlier instruction read or write this register?" and "does the later instruction read or write it?" — rather than pattern-matching on which instructions appear first.

    Full solution
  22. Q.32MSQ · 1 markOfficial answer: C, D
  23. Q.33MSQ · 1 markOfficial answer: A, B, D

    Programming in C › Pointers & arrays

    fX is just strlen written out by hand: b walks forward from a until it hits the terminating '\0', and b - a is the number of characters before it. It always returns some value as long as a points into a properly null-terminated block of memory — which is true for a string literal argument, for a local array initialised with "...", and for a pointer initialised with "...", since in every one of these cases the compiler lays down the characters followed by a '\0'.

    WATCH OUT FOR

    Assuming the loop can run past the end of allocated memory or that fX might not terminate — all three constructions (a string literal argument, a local array initialised from a literal, and a pointer initialised from a literal) guarantee a null-terminated block of memory, so the while(*b) loop always finds a '\0' and the function always returns; there is no case here where it fails to return.

    Full solution
  24. Q.34NAT · 1 markOfficial answer: 5
  25. Q.35NAT · 1 markOfficial answer: 3

    Data Structures and Algorithms › Design techniques

    Minimum replacements to make an array non-decreasing = − (length of the Longest Non-Decreasing Subsequence), because the untouched elements must themselves already form a non-decreasing subsequence, and any gaps left by replaced elements can always be filled with values that bridge them.

    WATCH OUT FOR

    Comparing the array with its sorted version, [1, 2, 2, 3, 4, 5, 6], and counting the positions that differ gives 5, because only positions 5 and 7 already match. The elements kept unchanged need only be in non-decreasing order among themselves, not in their final sorted positions, so the distance is minus the length of the longest non-decreasing subsequence: .

    Full solution
  26. Q.36MCQ · 2 marksOfficial answer: B

    Programming in C › Pointers & arrays

    Subtracting two pointers of the same type gives the number of array elements between them (the language defines it as the byte difference divided by the element's sizeof), not a raw byte offset — this is different from ordinary pointer-to-integer or byte-address reasoning.

    WATCH OUT FOR

    Assuming q - p returns the byte offset (sizeof(double) = 8) rather than the element count (1), which leads to wrongly picking option A (4,8) or C (8,5).

    Full solution
  27. Q.37MCQ · 2 marksOfficial answer: B
  28. Q.38MCQ · 2 marksOfficial answer: A
  29. Q.39MCQ · 2 marksOfficial answer: A

    Data Structures and Algorithms › Trees & heaps

    A BST's inorder traversal is always its elements in sorted order — this is a consequence of the left-smaller/right-larger invariant at every node, true for every possible tree shape a set can produce, so it depends only on the set V, never on the insertion sequence that built T. Root, preorder, and postorder all depend on which element was inserted first, which V alone does not reveal.

    WATCH OUT FOR

    Assuming that because you "don't have access to T" nothing about it can be recovered from V, and picking "none of the traversals is determined" reasoning, or conversely assuming the root (the most naturally guessed structural feature) is fixed by the set — both miss that inorder order is a value-based, shape-independent property while root/preorder/postorder are insertion-order-dependent.

    Full solution
  30. Q.40MCQ · 2 marksOfficial answer: A
  31. Q.41MCQ · 2 marksOfficial answer: B
  32. Q.42MCQ · 2 marksOfficial answer: B

    Data Structures and Algorithms › Design techniques

    Track two lengths in parallel — len1 for the run of the single most-recent value, len2 for the window of at most two distinct values — and derive each missing expression from what changes about the "previous" value when the current element repeats the second-to-last distinct value (P) versus introduces a brand-new third value (Q).

    WATCH OUT FOR

    Assuming len1 always just increments (using len1+1 for (P)) instead of recognizing that hitting the else if (X[i]==second) branch means X[i] is different from its immediate predecessor, so the single-value run must restart at 1; symmetrically, mistakenly using len2+1 for (Q) double-counts the old two-distinct window instead of correctly discarding the older of the two previous values and keeping only the immediately preceding run (len1) plus the new element.

    Full solution
  33. Q.43MCQ · 2 marksOfficial answer: A
  34. Q.44MCQ · 2 marksOfficial answer: D
  35. Q.45MCQ · 2 marksOfficial answer: B
  36. Q.46MSQ · 2 marksOfficial answer: B, C
  37. Q.47MSQ · 2 marksOfficial answer: A, B
  38. Q.48MSQ · 2 marksOfficial answer: B, C, D

    Data Structures and Algorithms › Linear structures

    GenerateOutput can only remove S1's current top element. To output an element buried under others, those elements must first be moved off S1 via PushToS2 — but S2 holds at most 2 elements at a time, so at most 2 elements can be "parked" and later restored (via PushToS1) to reach an element beneath them.

    WATCH OUT FOR

    Assuming any permutation reachable by "pop some, push some" is achievable without tracking S2's capacity limit of 2 — this wrongly admits sequences (like A) that need three elements moved off S1 before the first output.

    Full solution
  39. Q.49MSQ · 2 marksOfficial answer: A, B, D
  40. Q.50MSQ · 2 marksOfficial answer: C, D
  41. Q.51MSQ · 2 marksOfficial answer: D

    Data Structures and Algorithms › Graph algorithms

    Work with edge weights mod 2. If is any simple cycle and , then is a forest, which extends (using connectivity of ) to a spanning tree not containing ; since is a tree, the unique tree path between the endpoints of is exactly , so is precisely the fundamental cycle of with respect to . For any other edge of (so ), the tree is again a spanning tree of . Since both and must have even weight, . As was an arbitrary edge of , every edge of shares the same parity — this is exactly statement (D), and it holds for every graph satisfying the hypothesis.

    WATCH OUT FOR

    Assuming the hypothesis forces every edge weight to be even (choice A), or reasoning only about one spanning tree instead of using the exchange property across all spanning trees sharing a fundamental cycle; also mistakenly believing a "same overall parity across all edges" statement (B) follows, when two triangles of different fixed parities (one all-even, one all-odd) sharing a single vertex is a valid counterexample to B while still satisfying the hypothesis.

    Full solution
  42. Q.52MSQ · 2 marksOfficial answer: B, C
  43. Q.53NAT · 2 marksOfficial answer: 29.50 to 30.50

    Computer Organization and Architecture › Memory & cache

    When the sectors of a file are scattered randomly across the disk (not contiguous), the disk cannot amortize a single seek and a single rotational delay over the whole transfer. Every sector must be treated as an independent access: its own seek, its own average rotational latency, and its own transfer time — and these per-sector times are simply summed over all sectors in the file.

    WATCH OUT FOR

    Treating the 3000 sectors as one contiguous read: charging a single seek and a single rotational latency for the whole file and then adding only the total transfer time (3000 × 0.02 ms). That undercounts massively (a few seconds instead of ~30 s) because it ignores that "randomly located" sectors each require their own seek and rotational delay.

    Full solution
  44. Q.54NAT · 2 marksOfficial answer: 4
  45. Q.55NAT · 2 marksOfficial answer: 500
  46. Q.56NAT · 2 marksOfficial answer: 50
  47. Q.57NAT · 2 marksOfficial answer: 32

    Computer Organization and Architecture › Instructions & addressing

    Total instruction width is fixed at 32 bits; every field that is spelled out numerically (register fields, scalar field, addressing-mode field) eats into that budget, and whatever bits remain form the opcode field, whose size determines the count of distinct opcodes as .

    WATCH OUT FOR

    Forgetting to subtract the addressing-mode field bits before computing the opcode field width, i.e. taking opcode field = 32 − 24 = 8 bits directly (giving 2^8 = 256) instead of first removing the 3 bits needed to encode 8 addressing modes.

    Full solution
  48. Q.58NAT · 2 marksOfficial answer: 2.9 to 3.1

    Computer Organization and Architecture › Pipelining

    Speedup from pipelining = (execution time per instruction, non-pipelined) / (execution time per instruction, pipelined). Since both designs run at the same clock frequency, this reduces to the ratio of average CPIs: CPI_non-pipelined / CPI_pipelined, where CPI_pipelined = ideal CPI (1, since throughput is 1 instruction/cycle) plus the expected stall cycles per instruction from all hazards.

    WATCH OUT FOR

    Forgetting to add the base ideal CPI of 1 to the stall contributions (using average CPI = 0.4 + 0.6 = 1 instead of 1 + 0.4 + 0.6 = 2), which halves the pipelined execution time and gives a wrong speedup of 6.0; or forgetting that both designs run at the same clock frequency (2 GHz), so speedup can be computed directly as the ratio of average CPIs.

    Full solution
  49. Q.59NAT · 2 marksOfficial answer: 9

    Data Structures and Algorithms › Graph algorithms

    First pin down every edge that must belong to every MST (via the cut/exchange property — here the four disjoint weight-1 edges), which collapses the graph into a few components; then count only the ways to connect the remaining components at minimum extra cost, treating each such choice as an independent factor.

    WATCH OUT FOR

    Assuming that whichever edges look "cheapest overall" must all be forced, without checking (via the exchange/cut argument) that no equal-or-cheaper alternative path connects their endpoints; or, when counting, forgetting to verify that a candidate pair of connecting edges (e.g. two edges from the same component to g, or two direct X–Y edges) actually spans all remaining components before including it in the count — this can silently over- or under-count the multiplicative total.

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

    Computer Organization and Architecture › Instructions & addressing

    Each register field must hold bits. The OPCODE's Y bits split into 1 type-bit plus operation bits, which must distinguish the 75 instructions within EACH type (not all 150 together), so . The remaining bits in each 32-bit format go to UNUSED (R-type) or the immediate field (I-type).

    WATCH OUT FOR

    Assuming the OPCODE size only needs to distinguish 150 total instructions (giving Y=8 anyway by coincidence here, but conceptually wrong) or forgetting that the 1 type-bit is already included inside Y, causing double-counting; also using ceil(log2(150))=8 directly on the whole opcode without splitting off the type bit, and separately mis-sizing register fields as ceil(log2(50))=5 or 6 without checking 2^5=32<50.

    Full solution
  52. Q.62NAT · 2 marksOfficial answer: 15
  53. Q.63NAT · 2 marksOfficial answer: 4
  54. Q.64NAT · 2 marksOfficial answer: 1028
  55. Q.65NAT · 2 marksOfficial answer: 9