The GATE Grind

GATE 2021 CS (CS2) – Previous Year Questions with Solutions

All 65 questions of GATE 2021 CS (CS2) with answers and explanations. Read each question, then practise it by topic or as a full paper.

Practise this paper in The GATE Grind →

  1. Question 1 (1 mark, Multiple choice) – Gauri said that she can play the keyboard her sister.
  2. Question 2 (1 mark, Multiple choice) – A transparent square sheet is folded along the dotted vertical line, bringing the left half onto the right. Which option shows the folded sheet?
  3. Question 3 (1 mark, Multiple choice) – If θ is the angle between the longest diagonal of a cube and any edge, find cos θ.
  4. Question 4 (1 mark, Multiple choice) – If (x-12)2-(x-32)2=x+2, find x.
  5. Question 5 (1 mark, Multiple choice) – Pen : Write :: Knife :
  6. Question 6 (2 marks, Multiple choice) – Listening to music during exercise improves performance and reduces discomfort. Research on music while studying was inconclusive: students needing…
  7. Question 7 (2 marks, Multiple choice) – A jigsaw has two pieces. One is shown above the four candidate missing pieces. The pieces may be translated, rotated or flipped. Which missing piece…
  8. Question 8 (2 marks, Multiple choice) – Three classes initially have student counts in ratio 3:13:6. Adding 18 to every class changes the ratio to 15:35:21. Find the initial total.
  9. Question 9 (2 marks, Multiple choice) – The chart gives sales units and total net profits for three years. Cost per unit in Year 3 is 1, half that in Year 2 and one third that in Year 1. Tax…
  10. Question 10 (2 marks, Multiple choice) – P,Q,R,S,T,U have distinct heights. S is taller than R; Q is shortest; U is taller than only one student; T is taller than S but is not tallest. The…
  11. Question 11 (1 mark, Multiple choice) – G is connected, undirected and weighted. S1: Some minimum-weight edge of G is present in every MST. S2: If all edge weights are distinct, G has a…
  12. Question 12 (1 mark, Multiple choice) – A binary min-heap of n elements is stored in an array. Find the worst-case complexity of an optimal algorithm to find its maximum.
  13. Question 13 (1 mark, Multiple choice) – Which phase of a seven-phase ANSI C compiler reports the error? Assume Integer has not been declared as a type.
  14. Question 14 (1 mark, Multiple choice) – For IEEE 754 single precision, which exponent/fraction fields represent the smallest normalized positive value? The sign is zero.
  15. Question 15 (1 mark, Multiple choice) – Which 4-to-1 multiplexer implements f(x,y,z)=Σm(0,1,3,4,5,6), with select lines s1=y,s0=z?
  16. Question 16 (1 mark, Multiple choice) – S1: A relation schema can have at most one foreign key. S2: A foreign key in schema R cannot refer to tuples of R itself. Which are true?
  17. Question 17 (1 mark, Multiple choice) – P and Q choose initial TCP sequence numbers X and Y. P sends SYN=1,SEQ=X,ACK=0 to request a connection. Which header does Q return on accepting?
  18. Question 18 (1 mark, Multiple choice) – Find the worst-case number of arithmetic operations in recursive binary search on a sorted n-element array.
  19. Question 19 (1 mark, Multiple choice) – Regular L⊆0,1* has a minimal DFA with k states. Which language necessarily also has a minimal DFA with k states?
  20. Question 20 (1 mark, Multiple choice) – What is printed by this source C program under its contiguous-array addressing model?
  21. Question 21 (1 mark, Multiple select) – For n≥2, S1 contains all n×n matrices over a,b,c, and S2 contains all functions from \0,1,,n2-1\ to 0,1,2. Which are correct?
  22. Question 22 (1 mark, Multiple select) – L1 is regular and L2 is context-free. Which are necessarily context-free?
  23. Question 23 (1 mark, Multiple select) – Which are NOT intermediate representations of a source program?
  24. Question 24 (1 mark, Multiple select) – Which statements about CPU scheduling are correct?
  25. Question 25 (1 mark, Multiple select) – For S:((P Q) R)((P Q)(Q R)), choose the correct statements.
  26. Question 26 (1 mark, Numerical answer) – In a complete binary tree with seven nodes, A is the set of the first three nodes visited by root-started BFS and B the set of the first three visited…
  27. Question 27 (1 mark, Numerical answer) – For the DFA shown, how many binary strings of length eight are accepted?
  28. Question 28 (1 mark, Numerical answer) – For decimal digits x,y, (0.1101)₂=(0.8xy5)₁₀. Find x+y.
  29. Question 29 (1 mark, Numerical answer) – A byte-addressable set-associative cache is 2 KB, with 64-byte blocks and 32-bit addresses. Its tag is 22 bits wide. Find the associativity.
  30. Question 30 (1 mark, Numerical answer) – A 2 MHz processor supports cycle-stealing DMA. The DMA transfers one 8-bit character in one CPU cycle at regular intervals. If DMA uses 0.5% of CPU…
  31. Question 31 (1 mark, Numerical answer) – A sorted data file has 150000 student records and 4096-byte blocks. Disk record pointers are 7 bytes; candidate-key Anum is 12 bytes. A dense index…
  32. Question 32 (1 mark, Numerical answer) – A biased coin has P(head)=0.4. Let X count heads in 1000 independent tosses. Find its standard deviation, rounded to two decimal places.
  33. Question 33 (1 mark, Numerical answer) – Find SomeFunction(15,255).
  34. Question 34 (1 mark, Numerical answer) – P is a 4×5 matrix whose null space is spanned by [2,5,4,3,1]ᵀ. Find rank(P).
  35. Question 35 (1 mark, Numerical answer) – f is continuous on [−3,3] and differentiable on (−3,3), with f′(x)≤2. If f(−3)=7, find the greatest possible f(3).
  36. Question 36 (2 marks, Multiple choice) – Assign a binary prefix code to each letter of abbccdddee. For letters with equal frequencies, a letter earlier in dictionary order must have code…
  37. Question 37 (2 marks, Multiple choice) – L1 and larger L2 form an inclusive cache hierarchy. S1: Read misses in a write-through L1 never cause dirty-line writebacks to L2. S2: Write-allocate…
  38. Question 38 (2 marks, Multiple choice) – A synchronous circuit replaces the first 1 of every maximal run of consecutive ones by 0, leaving other bits unchanged. It is a two-state Mealy…
  39. Question 39 (2 marks, Multiple choice) – A student chooses the order for independent questions A,B. A is answered correctly with probability 0.8 and gives 10 marks; B has probability 0.5 and…
  40. Question 40 (2 marks, Multiple choice) – Apply common-subexpression elimination to the code. y points to a heap struct with f1,f2; x,y,z,p,q,i reside in registers. Count additions and…
  41. Question 41 (2 marks, Multiple choice) – emp(empId,name,gender,salary,deptId) has key empId, and each employee belongs to one department. What does this query count for each department? It…
  42. Question 42 (2 marks, Multiple choice) – Schedule S is R2(Y),R1(X),R3(Z),R1(Y),W1(X),R2(Z),W2(Y),R3(X),W3(Z). P: S is conflict-serializable. Q: If T3 commits before T1 finishes, S is…
  43. Question 43 (2 marks, Multiple choice) – A bag initially has r red and b black balls. In each trial, draw a ball uniformly, note its colour, then return it with one additional ball of the…
  44. Question 44 (2 marks, Multiple choice) – A CRC generator is X³+X+1. The five-bit message is 11000. Find the appended three-bit check sequence c2c1c0.
  45. Question 45 (2 marks, Multiple choice) – Which statement about this C program is correct?
  46. Question 46 (2 marks, Multiple choice) – S1: Every infinite regular language has an undecidable language as a subset. S2: Every finite language is regular. Which are true?
  47. Question 47 (2 marks, Multiple choice) – Define s(P,Q)= i=1nP[i]Q[i]. A set L of nonzero ten-dimensional real vectors satisfies s(P,Q)=0 for every distinct pair. Find the maximum L .
  48. Question 48 (2 marks, Multiple choice) – For statement S, USE(S) contains variables used in S; IN(S) those live at entry; OUT(S) those live at exit. A basic block consists of S1 immediately…
  49. Question 49 (2 marks, Multiple choice) – For constants a≥1,b>1, T(n)=aT(n/b)+f(n). Which general claim is correct, under the usual positive constant base-case assumptions?
  50. Question 50 (2 marks, Multiple select) – On U(P,Q,R,S,T), dependencies P→QR and RS→T hold. Which can be inferred?
  51. Question 51 (2 marks, Multiple select) – For binary strings, wR is reversal. Which languages are context-free? w,x may be empty.
  52. Question 52 (2 marks, Multiple select) – Processes P1,P2 each execute this code with ordinary process-private globals; each creates two threads. Which statements hold?
  53. Question 53 (2 marks, Multiple select) – There is one instance of each resource type. Under a global lock L, OwnResource(R) acquires R if available. Otherwise it terminates the other owner P,…
  54. Question 54 (2 marks, Multiple select) – The same two bytes interpreted as an unsigned integer have a little-endian numerical value 255 greater than their big-endian value. Which hexadecimal…
  55. Question 55 (2 marks, Multiple select) – Distance-vector router R has neighbours X,Y,Z with link costs 3,2,5. Their advertised distances to P are 7,6,5 and to Q are 4,6,8. R initially does…
  56. Question 56 (2 marks, Multiple select) – For the directed graph shown, which statements hold?
  57. Question 57 (2 marks, Multiple select) – Which regular expressions denote the binary numbers divisible by three? Leading zeros are allowed and ε is treated as divisible by three. Here + means…
  58. Question 58 (2 marks, Numerical answer) – A three-level page table translates 39-bit virtual addresses with fields: level-1 index 9 bits, level-2 index 9, level-3 index 9, page offset 12.…
  59. Question 59 (2 marks, Numerical answer) – What does this program print?
  60. Question 60 (2 marks, Numerical answer) – S has ten elements. How many ordered tuples (A,B) of subsets of S satisfy A⊆B?
  61. Question 61 (2 marks, Numerical answer) – The augmented grammar is S′→S; S→S#cS SS S@ <S> a b c, with #,@,<,>,a,b,c terminals. Let I0=CLOSURE(S′→·S). Find the number of LR(0) items in…
  62. Question 62 (2 marks, Numerical answer) – Boolean f(w,x,y,z) satisfies f(w,0,0,z)=1, f(1,x,1,z)=x+z, f(w,1,y,z)=wz+y. Find the number of literals in a minimal sum-of-products expression.
  63. Question 63 (2 marks, Numerical answer) – A five-stage pipeline has IF,ID,EX,MEM,WB. All stages take one cycle except EX: ADD takes one and MUL two. ID decodes and reads registers. Instruction…
  64. Question 64 (2 marks, Numerical answer) – A pure ALOHA network uses 1000-bit frames and a 1 Mbps link. The aggregate transmission rate, including retries, is a Poisson process of 1000…
  65. Question 65 (2 marks, Numerical answer) – In the DAG shown with source s, a path’s quality is the product of its edge weights. A vertex’s quality is the maximum path quality from s;…