IIT / IISc · Free practice

GATE Questions & Instant Answers

GATE CS previous-year-style questions across Algorithms, Data Structures, Theory of Computation, Operating Systems, DBMS, Computer Organization & Networks — the high-weightage, multi-step problems that decide your rank.

20 questionsStep-by-step solutionsComputer Science & Information Technology
AlgorithmsTheory of ComputationOperating SystemsDBMSComputer OrganizationNetworksDiscrete Maths
  1. 1Theory of ComputationHardNumerical

    What is the minimum number of states in a DFA that accepts all binary strings (read most-significant-bit first) whose value is divisible by 55?

    Show answer & solution
    Correct answer
    5
    Solution

    Track the remainder mod 55. On reading a bit bb, the value updates as r(2r+b)mod5r \to (2r + b) \bmod 5. The five remainders {0,1,2,3,4}\{0,1,2,3,4\} are all reachable and distinguishable, so exactly 55 states are needed, with remainder 00 as the only accepting state.

  2. 2Theory of ComputationMediumMCQ

    Which of the following languages over {a,b}\{a,b\} is REGULAR?

    • A) {anbnn0}\{a^n b^n \mid n \ge 0\}
    • B) {ww has equal as and bs}\{w \mid w \text{ has equal } a\text{s and } b\text{s}\}
    • C) {anbmn,m0}\{a^n b^m \mid n,m \ge 0\}
    • D) {www{a,b}}\{ww \mid w \in \{a,b\}^*\}
    Show answer & solution
    Correct answer
    C
    Solution

    {anbm}\{a^n b^m\} needs no counting — it is described by the regular expression aba^* b^*. The other three require matching/counting an unbounded quantity, which a finite automaton cannot do (provable via the pumping lemma).

  3. 3AlgorithmsHardMCQ

    The recurrence T(n)=2T(n/2)+nlognT(n) = 2\,T(n/2) + \dfrac{n}{\log n} solves to:

    • A) Θ(nlogn)\Theta(n \log n)
    • B) Θ(n)\Theta(n)
    • C) Θ(nloglogn)\Theta(n \log \log n)
    • D) Θ(n2)\Theta(n^2)
    Show answer & solution
    Correct answer
    C
    Solution

    The Master Theorem does not apply (the driving term is not a polynomial in nn). Summing costs over levels: level ii contributes nlogni\dfrac{n}{\log n - i}, so the total is nk=1logn1k=nH(logn)=Θ(nloglogn)n\sum_{k=1}^{\log n}\tfrac{1}{k} = n\,H(\log n) = \Theta(n \log \log n).

  4. 4AlgorithmsMediumMCQ

    Which statement about Dijkstra's shortestpathshortest-path algorithm is TRUE?

    • A) It always works correctly with negative edge weights
    • B) It can give incorrect results if any edge weight is negative
    • C) It requires the graph to be acyclic
    • D) It runs in Θ(V2)\Theta(V^2) regardless of implementation
    Show answer & solution
    Correct answer
    B
    Solution

    Dijkstra finalizes a vertex's distance greedily when extracted. A later negative edge could reduce that distance, but the vertex is never reconsidered — so a single negative edge can produce a wrong answer. (Bellman–Ford handles negative edges.)

  5. 5AlgorithmsMediumNumerical

    What is the minimum number of comparisons required to find BOTH the maximum and minimum among 100100 distinct numbers?

    Show answer & solution
    Correct answer
    148
    Solution

    Pair up elements (n/2n/2 comparisons), then compare pair-winners for the max and pair-losers for the min: 3n/22\lceil 3n/2 \rceil - 2. For n=100n=100: 1502=148150 - 2 = 148.

  6. 6Data StructuresHardNumerical

    What is the minimum number of nodes in an AVL tree of height 55 (height = number of edges on the longest root-to-leaf path)?

    Show answer & solution
    Correct answer
    20
    Solution

    Minimum nodes follow N(h)=N(h1)+N(h2)+1N(h) = N(h-1) + N(h-2) + 1 with N(0)=1, N(1)=2N(0)=1,\ N(1)=2. So N(2)=4, N(3)=7, N(4)=12, N(5)=20N(2)=4,\ N(3)=7,\ N(4)=12,\ N(5)=20.

  7. 7Computer OrganizationHardNumerical

    A 32bit32-bit byteaddressablebyte-addressable machine has a 16 KB, 4way4-way setassociativeset-associative cache with a 32byte32-byte block size. How many bits are in the TAG field?

    Show answer & solution
    Correct answer
    20
    Solution

    Blocks =16KB/32=512= 16\text{KB}/32 = 512. Sets =512/4=1287= 512/4 = 128 \Rightarrow 7 index bits. Offset =log232=5= \log_2 32 = 5 bits. Tag =3275=20= 32 - 7 - 5 = 20 bits.

  8. 8Computer OrganizationMediumNumerical

    A processor has ideal CPI =1= 1. Branch instructions are 20%20\% of the mix and each incurs a 22-cycle penalty. What is the effective CPI?

    Show answer & solution
    Correct answer
    1.4
    Solution

    Effective CPI =ideal CPI+(branch fraction)×(penalty)=1+0.2×2=1.4= \text{ideal CPI} + (\text{branch fraction}) \times (\text{penalty}) = 1 + 0.2 \times 2 = 1.4.

  9. 9Operating SystemsMediumNumerical

    Four processes arrive at time 00 with burst times 6,8,7,36, 8, 7, 3. Under Shortest-Job-First (non-preemptive), what is the average waiting time?

    Show answer & solution
    Correct answer
    7
    Solution

    SJF order: 3,6,7,83, 6, 7, 8. Waiting times: 0, 3, 9, 160,\ 3,\ 9,\ 16. Average =(0+3+9+16)/4=28/4=7= (0+3+9+16)/4 = 28/4 = 7.

  10. 10Operating SystemsMediumMCQ

    Belady's anomaly (more frames causing MORE page faults) can occur under which pagereplacementpage-replacement policy?

    • A) LRU
    • B) Optimal (OPT)
    • C) FIFO
    • D) Any stack algorithm
    Show answer & solution
    Correct answer
    C
    Solution

    FIFO is not a stack algorithm — its frame contents at kk frames are not guaranteed to be a subset of those at k+1k+1 frames, so adding a frame can increase faults. LRU and OPT are stack algorithms and are immune.

  11. 11DBMSHardNumerical

    Relation R(A,B,C,D)R(A,B,C,D) has FDs {AB, BC, CD, DA}\{A\to B,\ B\to C,\ C\to D,\ D\to A\}. How many superkeys does RR have?

    Show answer & solution
    Correct answer
    15
    Solution

    The FDs form a cycle, so every single attribute functionally determines all others — each attribute is a candidate key. Therefore every non-empty subset of the 44 attributes is a superkey: 241=152^4 - 1 = 15.

  12. 12DBMSMediumMCQ

    A schedule is conflictserializableconflict-serializable if and only if:

    • A) It is recoverable
    • B) Its precedence (serialization) graph is acyclic
    • C) It has no blind writes
    • D) All transactions commit
    Show answer & solution
    Correct answer
    B
    Solution

    ConflictserializabilityConflict-serializability is decided by the precedence graph built on conflicting operations (read–write, write–read, write–write on the same item). The schedule is conflictserializableconflict-serializable exactly when this graph has no cycle.

  13. 13Computer NetworksMediumNumerical

    How many usable host addresses are available in an IPv4 subnet with prefix length /26/26?

    Show answer & solution
    Correct answer
    62
    Solution

    Host bits =3226=626=64= 32 - 26 = 6 \Rightarrow 2^6 = 64 addresses. Subtract the network and broadcast addresses: 642=6264 - 2 = 62.

  14. 14Computer NetworksHardNumerical

    A Stop-and-Wait protocol runs over a link with one-way propagation delay 2020 ms and transmission time 11 ms per frame (ignore ACK transmission time). What is the link utilization (efficiency), rounded to two decimals?

    Show answer & solution
    Correct answer
    0.02
    Solution

    Efficiency =TtTt+2Tp=11+2(20)=1410.0240.02= \dfrac{T_t}{T_t + 2T_p} = \dfrac{1}{1 + 2(20)} = \dfrac{1}{41} \approx 0.024 \approx 0.02. This is why Stop-and-Wait is inefficient on high-latency links.

  15. 15Discrete MathsMediumNumerical

    How many ONTO (surjective) functions are there from a set of 44 elements to a set of 33 elements?

    Show answer & solution
    Correct answer
    36
    Solution

    By inclusion–exclusion: 34(31)24+(32)14=8148+3=363^4 - \binom{3}{1}2^4 + \binom{3}{2}1^4 = 81 - 48 + 3 = 36.

  16. 16Discrete MathsMediumNumerical

    How many reflexive relations can be defined on a set with 33 elements?

    Show answer & solution
    Correct answer
    64
    Solution

    Reflexivity fixes the nn diagonal pairs as present; the remaining n2nn^2 - n ordered pairs are free. Count =2n2n=293=26=64= 2^{n^2 - n} = 2^{9-3} = 2^6 = 64.

  17. 17Graph TheoryHardNumerical

    By Cayley’s formula, how many distinct labelled spanning trees does the complete graph K4K_4 have?

    Show answer & solution
    Correct answer
    16
    Solution

    Cayley's formula gives nn2n^{n-2} spanning trees for KnK_n. For n=4n=4: 442=42=164^{4-2} = 4^2 = 16.

  18. 18ProbabilityHardNumerical

    Two fair dice are rolled. Given that at least one die shows a 33, what is the probability that the sum equals 88? (give the fraction)

    Show answer & solution
    Correct answer
    2/112/11
    Solution

    Outcomes with at least one 33: 1111 (six with first die 33, six with second, minus the double-counted (3,3)(3,3)). Among these, sum =8=8 occurs for (3,5)(3,5) and (5,3)(5,3). So P=2/11P = 2/11.

  19. 19C ProgrammingMediumMCQ

    For int a[5] = {1,2,3,4,5}; $int *p = a$;, what does *$(p + 3) + 2$ evaluate to?

    • A) 55
    • B) 66
    • C) 44
    • D) undefined
    Show answer & solution
    Correct answer
    B
    Solution

    Pointer arithmetic: p + 3 points to a[3] =4= 4, so *(p+3) is 44. Then `4 + 2 = 6$.

  20. 20Linear AlgebraMediumNumerical

    If AA is a 3×33 \times 3 matrix with det(A)=2\det(A) = 2, what is det(2A)\det(2A)?

    Show answer & solution
    Correct answer
    16
    Solution

    For an n×nn \times n matrix, det(kA)=kndet(A)\det(kA) = k^n \det(A). Here det(2A)=23×2=8×2=16\det(2A) = 2^3 \times 2 = 8 \times 2 = 16.

✦ ClassScribe AI

Generate more questions & full mock tests like these — with AI

Turn any topic, PDF or lecture note into an exam-grade GATE paper in 12+ Indian languages — auto-graded with step-by-step explanations. Then share it with your whole class or study group in one tap.

🌐 12+ languages✅ Auto-graded + explanations👥 Share with students & peers
Generate with AI — free →

First questions free · No card needed