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
| Question | Type | Marks | Answer |
|---|---|---|---|
| Q.1 | MCQ | 1 | C |
| Q.2 | MCQ | 1 | A |
| Q.3 | MCQ | 1 | A |
| Q.4 | MCQ | 1 | C |
| Q.5 | MCQ | 1 | B |
| Q.6 | MCQ | 2 | C |
| Q.7 | MCQ | 2 | C |
| Q.8 | MCQ | 2 | D |
| Q.9 | MCQ | 2 | A |
| Q.10 | MCQ | 2 | A |
| Q.11 | MCQ | 1 | C |
| Q.12 | MCQ | 1 | A |
| Q.13 | MCQ | 1 | A |
| Q.14 | MCQ | 1 | B |
| Q.15 | MCQ | 1 | A |
| Q.16 | MCQ | 1 | B |
| Q.17 | MCQ | 1 | B |
| Q.18 | MCQ | 1 | B |
| Q.19 | MCQ | 1 | A |
| Q.20 | MCQ | 1 | A |
| Q.21 | MCQ | 1 | B |
| Q.22 | MCQ | 1 | A |
| Q.23 | MSQ | 1 | B |
| Q.24 | MSQ | 1 | B, C, D |
| Q.25 | MSQ | 1 | A, B |
| Q.26 | MSQ | 1 | A, B |
| Q.27 | MSQ | 1 | A, C, D |
| Q.28 | MSQ | 1 | B, C |
| Q.29 | MSQ | 1 | B, D |
| Q.30 | MSQ | 1 | B, C |
| Q.31 | MSQ | 1 | A |
| Q.32 | MSQ | 1 | C, D |
| Q.33 | MSQ | 1 | A, B, D |
| Q.34 | NAT | 1 | 5 |
| Q.35 | NAT | 1 | 3 |
| Q.36 | MCQ | 2 | B |
| Q.37 | MCQ | 2 | B |
| Q.38 | MCQ | 2 | A |
| Q.39 | MCQ | 2 | A |
| Q.40 | MCQ | 2 | A |
| Q.41 | MCQ | 2 | B |
| Q.42 | MCQ | 2 | B |
| Q.43 | MCQ | 2 | A |
| Q.44 | MCQ | 2 | D |
| Q.45 | MCQ | 2 | B |
| Q.46 | MSQ | 2 | B, C |
| Q.47 | MSQ | 2 | A, B |
| Q.48 | MSQ | 2 | B, C, D |
| Q.49 | MSQ | 2 | A, B, D |
| Q.50 | MSQ | 2 | C, D |
| Q.51 | MSQ | 2 | D |
| Q.52 | MSQ | 2 | B, C |
| Q.53 | NAT | 2 | 29.50 to 30.50 |
| Q.54 | NAT | 2 | 4 |
| Q.55 | NAT | 2 | 500 |
| Q.56 | NAT | 2 | 50 |
| Q.57 | NAT | 2 | 32 |
| Q.58 | NAT | 2 | 2.9 to 3.1 |
| Q.59 | NAT | 2 | 9 |
| Q.60 | NAT | 2 | 2 |
| Q.61 | NAT | 2 | 34 |
| Q.62 | NAT | 2 | 15 |
| Q.63 | NAT | 2 | 4 |
| Q.64 | NAT | 2 | 1028 |
| Q.65 | NAT | 2 | 9 |
General Aptitude Q.1 to Q.10
- Q.1MCQ · 1 markOfficial answer: C
- Q.2MCQ · 1 markOfficial answer: A
- Q.3MCQ · 1 markOfficial answer: A
- Q.4MCQ · 1 markOfficial answer: C
- Q.5MCQ · 1 markOfficial answer: B
- Q.6MCQ · 2 marksOfficial answer: C
- Q.7MCQ · 2 marksOfficial answer: C
- Q.8MCQ · 2 marksOfficial answer: D
- Q.9MCQ · 2 marksOfficial answer: A
- Q.10MCQ · 2 marksOfficial answer: A
Computer Science and Information Technology Q.11 to Q.65
- 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 FORFull solutionThe 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).
- Q.12MCQ · 1 markOfficial answer: A
- 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 FORFull solutionAssuming that "right to left evaluation" also means the parameters are somehow bound out of order inside
f, e.g. treatingyas if it heldg(10)'s value becauseh(20)was evaluated first. Evaluation order only changes when the side effects (theprintfcalls insidegandhas 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). - Q.14MCQ · 1 markOfficial answer: B
- 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 FORFull solutionAssuming 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 .
- Q.16MCQ · 1 markOfficial answer: B
- Q.17MCQ · 1 markOfficial answer: B
- Q.18MCQ · 1 markOfficial answer: B
- Q.19MCQ · 1 markOfficial answer: A
- Q.20MCQ · 1 markOfficial answer: A
- Q.21MCQ · 1 markOfficial answer: B
- Q.22MCQ · 1 markOfficial answer: A
- Q.23MSQ · 1 markOfficial answer: B
- Q.24MSQ · 1 markOfficial answer: B, C, D
- Q.25MSQ · 1 markOfficial answer: A, B
- Q.26MSQ · 1 markOfficial answer: A, B
- Q.27MSQ · 1 markOfficial answer: A, C, D
- Q.28MSQ · 1 markOfficial answer: B, C
- Q.29MSQ · 1 markOfficial answer: B, D
- Q.30MSQ · 1 markOfficial answer: B, C
- 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 FORFull solutionAssuming 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.
- Q.32MSQ · 1 markOfficial answer: C, D
- Q.33MSQ · 1 markOfficial answer: A, B, D
Programming in C › Pointers & arrays
fXis juststrlenwritten out by hand:bwalks forward fromauntil it hits the terminating'\0', andb - ais the number of characters before it. It always returns some value as long asapoints 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 FORFull solutionAssuming the loop can run past the end of allocated memory or that
fXmight 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 thewhile(*b)loop always finds a'\0'and the function always returns; there is no case here where it fails to return. - Q.34NAT · 1 markOfficial answer: 5
- 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 FORFull solutionComparing 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: .
- 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 FORFull solutionAssuming
q - preturns 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). - Q.37MCQ · 2 marksOfficial answer: B
- Q.38MCQ · 2 marksOfficial answer: A
- 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 FORFull solutionAssuming 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.
- Q.40MCQ · 2 marksOfficial answer: A
- Q.41MCQ · 2 marksOfficial answer: B
- 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 FORFull solutionAssuming 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. - Q.43MCQ · 2 marksOfficial answer: A
- Q.44MCQ · 2 marksOfficial answer: D
- Q.45MCQ · 2 marksOfficial answer: B
- Q.46MSQ · 2 marksOfficial answer: B, C
- Q.47MSQ · 2 marksOfficial answer: A, B
- Q.48MSQ · 2 marksOfficial answer: B, C, D
Data Structures and Algorithms › Linear structures
GenerateOutputcan only remove S1's current top element. To output an element buried under others, those elements must first be moved off S1 viaPushToS2— but S2 holds at most 2 elements at a time, so at most 2 elements can be "parked" and later restored (viaPushToS1) to reach an element beneath them.WATCH OUT FORFull solutionAssuming 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.
- Q.49MSQ · 2 marksOfficial answer: A, B, D
- Q.50MSQ · 2 marksOfficial answer: C, D
- 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 FORFull solutionAssuming 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.
- Q.52MSQ · 2 marksOfficial answer: B, C
- 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 FORFull solutionTreating 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.
- Q.54NAT · 2 marksOfficial answer: 4
- Q.55NAT · 2 marksOfficial answer: 500
- Q.56NAT · 2 marksOfficial answer: 50
- 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 FORFull solutionForgetting 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.
- 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 FORFull solutionForgetting 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.
- 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 FORFull solutionAssuming 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.
- Q.60NAT · 2 marksOfficial answer: 2
- 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 FORFull solutionAssuming 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.
- Q.62NAT · 2 marksOfficial answer: 15
- Q.63NAT · 2 marksOfficial answer: 4
- Q.64NAT · 2 marksOfficial answer: 1028
- Q.65NAT · 2 marksOfficial answer: 9