GATE 2026 Previous Year Questions (PYQs) with Solutions

Real questions from the GATE 2026 paper, solved. Every question below shows its options, the correct answer, and a full text solution — free to read, no login needed. Open any question to practice it interactively inside its course.

Questions: 
135
With solutions: 
135
  1. Q1.GATE 2026

    Expedite, Hasten, Hurry, ________

    Fill the blank by choosing a word with a meaning similar to that of the words given above.

    1. A.

      Accelerate

    2. B.

      Retard

    3. C.

      Provide

    4. D.

      Disable

    Correct answer: A

    Solution

    The words “expedite”, “hasten”, and “hurry” all mean to speed up or make something happen faster.

    The word with the same meaning is “Accelerate”.

    Therefore, the correct answer is Accelerate.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  2. Q2.GATE 2026

    A black square PQRS has been cut into two parts. One part of it is shown in Panel I. Which one of the shapes in Panel II is the other part?

    image.png

    1. A.

      (i)

    2. B.

      (ii)

    3. C.

      (iii)

    4. D.

      (iv)

    Correct answer: C

    Solution

    Compare the boundaries of the given part in Panel I with the candidate pieces in Panel II. The required second part must fill the white stepped cut-out exactly so that the two pieces together form the original square PQRS.

    The missing outline has one vertical projection and one horizontal stepped projection arranged in the same orientation as shape (iii). Shapes (i), (ii), and (iv) either place the projections on the wrong side or form a mirror orientation that will not fit the gaps in Panel I.

    Therefore, the other part is shape (iii).

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  3. Q3.GATE 2026

    A day can only be cloudy or sunny. The probability of a day being cloudy is 0.5, independent of the condition on other days.

    What is the probability that in any given four days, there will be three cloudy days and one sunny day?

    1. A.

      1/4

    2. B.

      3/4

    3. C.

      2/3

    4. D.

      3/8

    Correct answer: A

    Solution

    Each day is independently cloudy with probability 1/2 and sunny with probability 1/2.

    We need exactly 3 cloudy days and 1 sunny day in 4 days.

    Choose the position of the sunny day: C(4,1) = 4 ways.
    Probability of any one such sequence = (1/2)^4 = 1/16.

    Required probability = 4 × 1/16 = 1/4.

    Therefore, the probability is 1/4.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  4. Q4.GATE 2026

    The values of Stock A and Stock B on a particular day are Rs. 50 and Rs. 80, respectively.

    An investor invests Rs. 100 in Stock A and Rs. 80 in Stock B. He sells all the stocks the next day when:

    • Stock A = Rs. 55

    • Stock B = Rs. 70

    The profit made by the investor is Rs. ________

    1. A.

      0

    2. B.

      5

    3. C.

      10

    4. D.

      20

    Correct answer: A

    Solution

    Stock A price initially = Rs. 50. Investment in A = Rs. 100, so number of shares of A = 100/50 = 2.
    Next day price of A = Rs. 55, so selling value = 2 × 55 = Rs. 110. Profit from A = 110 - 100 = Rs. 10.

    Stock B price initially = Rs. 80. Investment in B = Rs. 80, so number of shares of B = 80/80 = 1.
    Next day price of B = Rs. 70, so selling value = 1 × 70 = Rs. 70. Loss from B = 80 - 70 = Rs. 10.

    Net profit = 10 - 10 = Rs. 0.

    Therefore, the profit made by the investor is Rs. 0.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  5. Q5.GATE 2026

    “When it is raining, peacocks dance.”

    Based only on this sentence, which one of the following options is necessarily true?

    1. A.

      Peacocks dance only when it is raining.

    2. B.

      When peacocks dance, it is raining.

    3. C.

      When peacocks are not dancing, it is not raining.

    4. D.

      When it is not raining, peacocks do not dance.

    Correct answer: C

    Solution

    Let R mean “it is raining” and D mean “peacocks dance”.

    The given sentence says: R -> D.

    The only logically equivalent necessary statement among the options is the contrapositive: not D -> not R.

    In words, if peacocks are not dancing, then it is not raining.

    Therefore, the necessarily true option is: “When peacocks are not dancing, it is not raining.”

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  6. Q6.GATE 2026

    Water : P :: Food : Q

    Choose the P and Q combination from the options below to form a meaningful analogy.

    1. A.

      P = Thirst; Q = Hunger

    2. B.

      P = Drink; Q = Hunger

    3. C.

      P = Thirst; Q = Satiated

    4. D.

      P = Wet; Q = Critic

    Correct answer: A

    Solution

    The analogy should use the same relationship on both sides. Water is used to satisfy thirst. Similarly, food is used to satisfy hunger.

    So P = Thirst and Q = Hunger.

    Therefore, the correct option is P = Thirst; Q = Hunger.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  7. Q7.GATE 2026

    Two tiles are missing in Panel I. Which one of the options in Panel II is the appropriate choice for the missing tiles?

    image.png

    1. A.

      (i)

    2. B.

      (ii)

    3. C.

      (iii)

    4. D.

      (iv)

    Correct answer: A

    Solution

    Count the black dots in each tile. In Panel I, the first row has 8 + 1 + 6 = 15 black dots. The first column has 8 + 3 + 4 = 15 black dots, and the second column has 1 + 5 + 9 = 15 black dots. Therefore the same total of 15 must be maintained for every row and column.

    For the second row, the upper missing tile must have 15 - (3 + 5) = 7 black dots. For the third row, the lower missing tile must have 15 - (4 + 9) = 2 black dots. Only option (i) gives a vertical pair with 7 black dots in the upper tile and 2 black dots in the lower tile. Hence option (i) is correct.

    Practice this question →

  8. Q8.GATE 2026

    Figures (i) and (ii) represent intercity highway systems. The black dots represent cities and the line segments between them represent intercity highways.

    A salesperson needs to make a trip. She needs to:

    • Start from a city

    • Visit each remaining city exactly once

    • Return to the starting city

    Which one of the following options is true?

    image.png

    1. A.

      Such a trip is possible for (i), but not for (ii).

    2. B.

      Such a trip is possible for (ii), but not for (i).

    3. C.

      Such a trip is possible for both (i) and (ii).

    4. D.

      Such a trip is possible neither for (i) nor for (ii).

    Correct answer: A

    Solution

    Concept

    A Hamiltonian cycle is a closed walk in a graph that visits every vertex exactly once before returning to the start — exactly the "visit each city once and return" trip the question describes. This is different from an Euler circuit, which instead must traverse every edge exactly once and requires every vertex to have even degree; Euler circuits are not relevant here because the constraint in this question is on cities (vertices), not on roads (edges).

    A useful fact for checking existence: if a vertex has degree 2, both of its incident edges must be part of any Hamiltonian cycle passing through it, since there is no alternative edge available. When several such degree-2 vertices are all forced to share the same one or two neighbours, this can force a neighbour to need more cycle-edges than a cycle allows — giving a quick way to rule a graph out.

    Application

    Figure (i) is a 4×4 grid graph (16 vertices). Labelling positions (row, column) with rows and columns numbered 1–4, an explicit closed route through every vertex is:

    1. Traverse row 1 left to right: (1,1) → (1,2) → (1,3) → (1,4).

    2. Drop to row 2 and traverse right to left, stopping one column early: (1,4) → (2,4) → (2,3) → (2,2).

    3. Drop to row 3 and traverse left to right, stopping one column early: (2,2) → (3,2) → (3,3) → (3,4).

    4. Drop to row 4 and traverse right to left across all four columns: (3,4) → (4,4) → (4,3) → (4,2) → (4,1).

    5. Climb back up column 1 through row 3 and row 2: (4,1) → (3,1) → (2,1).

    6. Close the cycle: (2,1) → (1,1).

    This route touches all 16 vertices exactly once and returns to the start, so figure (i) admits the required trip.

    Figure (ii) has 5 vertices. Two of them (call the top-left vertex and the bottom-right vertex) each connect to three other vertices; the remaining three vertices each connect to exactly those same two vertices and nothing else — each has degree 2.

    1. Each of the three degree-2 vertices has only two edges available, both going to the top-left and bottom-right vertices, so any Hamiltonian cycle passing through one of them must use both of its edges — there is no other edge to substitute.

    2. Applying this to all three degree-2 vertices forces all three of their edges toward the top-left vertex to be included in the cycle, which would give that single vertex three cycle-edges.

    3. A Hamiltonian cycle can only use exactly two cycle-edges at every vertex, so three forced edges at one vertex is a contradiction.

    4. Therefore figure (ii) cannot have a Hamiltonian cycle.

    Cross-check

    Running the same forcing argument from the bottom-right vertex instead of the top-left one gives an identical contradiction — all three degree-2 vertices equally force their edge toward the bottom-right vertex, again demanding three cycle-edges there. Both directions agree, confirming figure (ii) has no Hamiltonian cycle, while the explicit 16-step route above confirms figure (i) does.

    So the trip described is possible for figure (i) but not for figure (ii).

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  9. Q9.GATE 2026

    The figure in Panel I is a 4×4 grid.

    The numbers on the top and left represent the number of cells to be shaded in that column and row respectively.

    Which one of the options in Panel II represents the correctly shaded grid?

    image.png

    1. A.

      (i)

    2. B.

      (ii)

    3. C.

      (iii)

    4. D.

      (iv)

    Correct answer: B

    Solution

    From Panel I, the required row counts from top to bottom are 3, 1, 2, and 2. The required column counts from left to right are 2, 2, 2, and 2.

    Check each option against both sets of counts.

    Option (ii) has 3 shaded cells in the first row, 1 in the second row, 2 in the third row, and 2 in the fourth row. Its four columns also each contain exactly 2 shaded cells.

    The other options fail at least one row or column count.

    Therefore, the correctly shaded grid is option (ii).

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  10. Q10.GATE 2026

    An unbiased six-faced dice whose faces are marked with numbers 1, 2, 3, 4, 5, and 6 is rolled twice in succession and the number on the top face is recorded each time. The probability that the sum of the two recorded numbers is a prime number is....?

    1. A.

      3/36

    2. B.

      13/36

    3. C.

      15/36

    4. D.

      19/36

    Correct answer: C

    Solution

    There are 6 x 6 = 36 equally likely ordered outcomes when the die is rolled twice. The possible prime sums are 2, 3, 5, 7 and 11. Their counts are: sum 2 -> 1 outcome, sum 3 -> 2 outcomes, sum 5 -> 4 outcomes, sum 7 -> 6 outcomes, and sum 11 -> 2 outcomes. Thus the number of favourable outcomes is 1 + 2 + 4 + 6 + 2 = 15. Therefore the required probability is 15/36. Hence option C is correct.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  11. Q11.GATE 2026

    For two different persons 𝑥 and 𝑦, the predicate 𝑀(𝑥, 𝑦) denotes that x knows y. Consider the following statement.
    There is a person who does not know anyone else, but that person is known by everyone else.
    Which one of the following expressions represents the above statement?

    1. A.

      (∃y)(∀x) ((x ≠ y) → (M(x,y) ∧ ¬M(y,x)))

    2. B.

      (∀y)(∃x) ((x ≠ y) → (M(x,y) ∧ ¬M(y,x)))

    3. C.

      (∃y)(∃x) ((x ≠ y) → (M(x,y) ∧ ¬M(y,x)))

    4. D.

      (∀y)(∀x) ((x ≠ y) → (M(x,y) ∧ ¬M(y,x)))

    Correct answer: A

    Solution

    Step-by-Step Solution

    Let's break down the statement: "There is a person who does not know anyone else, but that person is known by everyone else."

    1. Analyze the Subject

    The phrase "There is a person" indicates an existential quantifier (∃). Let's call this person y. So, we start with (∃y).

    2. Analyze the Condition for Others

    The phrase "everyone else" refers to all other persons x. This requires a universal quantifier (∀). So, for the person y, the condition must hold for all x where x ≠ y.

    3. Translate the Relationships

    The statement has two parts for the relationship between x and y (where x ≠ y):

    • "that person is known by everyone else": This means x knows y, represented as M(x, y).

    • "who does not know anyone else": This means y does not know x, represented as ¬M(y, x).

    These two conditions must be true simultaneously, so we use the AND operator (∧).

    4. Construct the Final Expression

    Combining the quantifiers and the condition:

    For all x (where x ≠ y), M(x, y) is true AND ¬M(y, x) is true.

    There exists a y such that for all x (where x ≠ y), the condition holds.

    Expression: (∃y)(∀x) ((x ≠ y) → (M(x,y) ∧ ¬M(y,x)))

    Conclusion

    The correct expression corresponds to Option A.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  12. Q12.GATE 2026

    Match the following :

    image.png

    1. A.

      I–L, II–M, III–N

    2. B.

      I–M, II–L, III–N

    3. C.

      I–N, II–M, III–L

    4. D.

      I–L, II–N, III–M

    Correct answer: C

    Solution

    The correct matching is based on the Three-Schema Architecture of a Database Management System.

    1. External Schema (III): This level describes the user views. It matches with L: Views.

    2. Logical Schema (I): This level describes the structure of the whole database, typically using relations. It matches with N: Relations.

    3. Physical Schema (II): This level describes how data is stored, including file organization and indexes. It matches with M: File organization and indexes.

    Therefore, the correct matching is I–N, II–M, III–L.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  13. Q13.GATE 2026

    Which statement is equivalent to:
    Turing machine M decides language L ⊆ {0,1}*

    1. A.

      Turing machine 𝑀 halts on all input strings in {0,1}

    2. B.

      Turing machine 𝑀 accepts all input strings in L

    3. C.

      Turing machine 𝑀 rejects all input strings in {0,1}−L

    4. D.

      Turing machine 𝑀 accepts all input strings in 𝐿 and rejects all input strings in {0,1} − 𝐿

    Correct answer: D

    Solution

    A Turing machine M decides a language L if it satisfies two main conditions for every input string w.

    First, M must halt on all inputs, meaning it never enters an infinite loop.

    Second, M must accept w if w is in L, and reject w if w is not in L.

    This combination ensures that for any input, the machine provides a definitive decision (accept or reject) in finite time.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  14. Q14.GATE 2026

    The probability density function 𝑓(𝑥) of a random variable 𝑋 which takes real values is

    image.png

    Which one of the following statements is correct about the random variable 𝑋 ?

    1. A.

      Exponential

    2. B.

      Normal

    3. C.

      Poisson

    4. D.

      Uniform

    Correct answer: B

    Solution

    The standard normal-family density is f(x) = (1/(σ√(2π))) exp(-(x - μ)²/(2σ²)), for -∞ < x < ∞. The given density is (1/(3√(2π))) exp(-x²/18). Comparing terms gives μ = 0 and 2σ² = 18, so σ² = 9 and σ = 3. Therefore X follows a normal distribution. The correct option is Normal.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  15. Q15.GATE 2026

    The set T represents various traversals over binary tree. The set S represents the order of visiting nodes during a traversal.

    image.png

    Which one of the following is the correct match from T to S ?

    1. A.

      I–L, II–M, III–N

    2. B.

      I–M, II–L, III–N

    3. C.

      I–N, II–M, III–L

    4. D.

      I–N, II–L, III–M

    Correct answer: A

    Solution

    To solve this, we need to match the traversal names in set T with their visiting orders in set S.

    1. Inorder Traversal (I)

    In an Inorder traversal, we visit the left subtree first, then the current node, and finally the right subtree. This corresponds to order: left subtree, node, right subtree. This matches description L.

    2. Preorder Traversal (II)

    In a Preorder traversal, we visit the current node first, then the left subtree, and finally the right subtree. This corresponds to order: node, left subtree, right subtree. This matches description M.

    3. Postorder Traversal (III)

    In a Postorder traversal, we visit the left subtree first, then the right subtree, and finally the current node. This corresponds to order: left subtree, right subtree, node. This matches description N.

    Conclusion

    Based on the above analysis: - I matches with L - II matches with M - III matches with N Therefore, the correct match is I–L, II–M, III–N.

    Practice this question →

  16. Q16.GATE 2026

    Which one of the following options is not a property of Boolean Algebra?
    (+ denotes OR, . denotes AND, ′ denotes NOT)

    1. A.

      a+b=b+a

    2. B.

      a.a′=1

    3. C.

      a+a′=1

    4. D.

      a.b=b.a

    Correct answer: B

    Solution

    Boolean Algebra follows specific laws. The Complement Law states that a variable ANDed with its negation equals 0 (a.a′ = 0), not 1. Options representing the Commutative Law and the OR Complement Law (a+a′ = 1) are valid properties. Since option 1 claims a.a′ = 1, it is incorrect and thus the answer.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  17. Q17.GATE 2026

    In C runtime environment, which one of the following is stored in heap?

    1. A.

      A static variable declared inside a function

    2. B.

      An array of integers declared inside a function

    3. C.

      A dynamically allocated array of integers created using malloc() function call

    4. D.

      Return address of a function

    Correct answer: C

    Solution

    The correct answer is CA dynamically allocated array of integers created using malloc() function call.

    In C runtime memory organization:

    • Heap → stores dynamically allocated memory using malloc(), calloc(), realloc()

    • Stack → stores local variables, function parameters, return addresses

    • Data segment → stores static and global variables

    So:

    • A → Static variable → Data segment

    • B → Local array inside function → Stack

    • Cmalloc() allocated array → Heap ✅

    • D → Return address → Stack

    Practice this question →

  18. Q18.GATE 2026

    Consider the following two statements about interrupt handling mechanisms in a CPU.

    S1: In non-vectored interrupt mechanism, it usually takes more time to start the Interrupt Service Routine (ISR) when compared to that in a vectored interrupt mechanism.

    S2: In daisy-chain interrupt mechanism, the CPU polls all the input devices individually to determine the source of the interrupt.

    Which one of the following options is correct?

    1. A.

      Both S1 and S2 are true

    2. B.

      Both S1 and S2 are false

    3. C.

      S1 is true and S2 is false

    4. D.

      S1 is false and S2 is true

    Correct answer: C

    Solution

    Statement S1

    In non-vectored interrupt mechanism, it usually takes more time to start the Interrupt Service Routine (ISR) when compared to that in a vectored interrupt mechanism.

    This statement is True.

    In a vectored interrupt, the interrupting device directly provides the ISR address (or vector number), so the CPU can immediately jump to the corresponding ISR.

    In a non-vectored interrupt, the CPU must first identify which device generated the interrupt, usually through additional checking or polling. This extra step increases the interrupt response time.

    Therefore, non-vectored interrupts generally take more time to begin ISR execution.

    Statement S2

    In daisy-chain interrupt mechanism, the CPU polls all the input devices individually to determine the source of the interrupt.

    This statement is False.

    In a daisy-chain interrupt mechanism, devices are connected serially according to priority. The interrupt acknowledge signal passes through the chain, and the highest-priority requesting device captures it and responds.

    The CPU does not poll every device individually. Priority resolution is handled by the hardware chain itself.

    Correct Option

    Option C: S1 is true and S2 is false

    Practice this question →

  19. Q19.GATE 2026

    Consider the following three ANSI-C programs P1, P2, and P3.

    image.png

    Which one of the following statements is true?

    1. A.

      Only P1 will compile without any error

    2. B.

      Only P2 will compile without any error

    3. C.

      Only P3 will compile without any error

    4. D.

      All three programs P1, P2, and P3 will compile without any error

    Correct answer: A

    Solution

    Analysis of Programs

    To determine which program compiles, we analyze the variable declarations in each:

    Program P1

    P1 declares a global variable `int a=5;`. Inside `main`, it declares a local variable `int a=7;`. In C, a local variable can shadow a global variable with the same name. This is valid syntax.

    Program P2

    P2 declares `int a=5;` and then `int a=7;` inside the same function scope. C does not allow redeclaring a variable with the same name in the same block. This causes a compilation error.

    Program P3

    P3 declares `int a=5;` and then `float a=7;` inside the same function scope. Similar to P2, redeclaring a variable name in the same block is invalid, regardless of the data type. This causes a compilation error.

    Conclusion

    Only P1 compiles without any error. P2 and P3 fail due to variable redeclaration errors.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  20. Q20.GATE 2026

    Consider a file of size 4 million bytes being transferred between two hosts connected via three consecutive links of bandwidth 2 Mbps, 500 kbps, and 1 Mbps, respectively.
    All processing delays and propagation delays are negligible.
    Assume that there is no other background traffic over the path and no other additional overhead to transfer the file.

    What is the total time (in seconds) to transfer the file?
    Note: 1M=106 , 1k=103

    1. A.

      731

    2. B.

      64

    3. C.

      8

    4. D.

      16

    Correct answer: B

    Solution

    To find the total transfer time, first convert the file size from bytes to bits. Then, identify the bottleneck bandwidth among the three links. Finally, divide the total bits by the bottleneck bandwidth.

    File Size = 4 million bytes = 4 * 10^6 * 8 bits = 32 * 10^6 bits.

    Bandwidths: 2 Mbps, 500 kbps, 1 Mbps. Bottleneck = 500 kbps = 0.5 * 10^6 bps.

    Time = 32 * 10^6 / 0.5 * 10^6 = 64 seconds.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  21. Q21.GATE 2026

    Which one of the following protocols may need to broadcast some of its messages?

    1. A.

      SMTP

    2. B.

      FTP

    3. C.

      DHCP

    4. D.

      HTTP

    Correct answer: C

    Solution

    Network protocols utilize different communication methods depending on their purpose. Some operate over direct connections, while others require reaching multiple devices simultaneously.

    SMTP, FTP, and HTTP typically function using unicast communication. They establish dedicated links between a specific client and server to exchange data securely and efficiently.

    DHCP, however, often requires broadcasting messages during the initial configuration phase. A client sends a broadcast discovery packet to find a DHCP server on the local network without knowing its IP address.

    Therefore, among the given options, DHCP is the protocol that may need to broadcast some of its messages to function correctly.

    Practice this question →

  22. Q22.GATE 2026

    Which one of the following CPU scheduling algorithms cannot be preemptive?

    1. A.

      Shortest Remaining Time First (SRTF) Scheduling

    2. B.

      First Come First Serve (FCFS) Scheduling

    3. C.

      Round Robin Scheduling

    4. D.

      Priority Scheduling

    Correct answer: B

    Solution

    First Come First Serve (FCFS) is inherently non-preemptive because once a process begins execution, it runs to completion. Other algorithms like Round Robin allow interruption based on time slices or priority changes.

    Practice this question →

  23. Q23.GATE 2026

    Consider the following functions where n is a positive integer:

    n1/3, log⁡(n), log⁡(n!), 2log⁡(n)

    Which one of the following lists the functions in increasing order of asymptotic growth rate?

    1. A.

      log⁡(n), n1/3, 2log⁡(n), log⁡(n!)

    2. B.

      n1/3, log⁡(n), log⁡(n!), 2log⁡(n)

    3. C.

      log⁡(n), n1/3, log⁡(n!), 2log⁡(n)

    4. D.

      2log⁡(n), n1/3, log⁡(n), log⁡(n!)

    Correct answer: A

    Solution

    Step-by-Step Asymptotic Analysis

    To determine the increasing order of asymptotic growth rates, we analyze the behavior of each function as n approaches infinity.

    1. Analyze Individual Functions

    • log(n): Grows logarithmically. This is the slowest growth among the given functions.

    • n^(1/3): Grows as a fractional power of n. Polynomial growth (even with a small exponent) is faster than logarithmic growth.

    • 2 log(n): This is a constant multiple of log(n). In asymptotic analysis, constant factors are ignored, so 2 log(n) = Θ(log(n)). It grows at the same rate as log(n).

    • log(n!): Using Stirling's approximation, log(n!) ≈ n log(n). This grows faster than any polynomial n^k (where k < 1) and significantly faster than log(n).

    2. Compare Growth Rates

    Comparing the functions:

    • log(n) vs n^(1/3): log(n) grows slower than n^(1/3).

    • n^(1/3) vs 2 log(n): n^(1/3) grows faster than 2 log(n) because polynomial growth dominates logarithmic growth.

    • 2 log(n) vs log(n!): Since 2 log(n) is Θ(log(n)) and log(n!) is Θ(n log(n)), log(n!) grows much faster.

    3. Final Ordering

    The correct increasing order of asymptotic growth rates is:

    log(n) < n^(1/3) < 2 log(n) < log(n!)

    Note: While log(n) and 2 log(n) are in the same complexity class, in terms of specific values for large n, 2 log(n) is strictly greater than log(n). However, the primary distinction is that n^(1/3) sits between the logarithmic terms and the factorial logarithm.

    Thus, the list corresponding to this order is Option C.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  24. Q24.GATE 2026

    Which of the following can be recurrence relation(s) corresponding to an algorithm with time complexity Θ(n)?

    1. A.

      T(n)=T(n−1)+1 𝑇(1) = 1

    2. B.

      T(n)=2T(n/2)+1 𝑇(1) = 1

    3. C.

      T(n)=2T(n/2)+n 𝑇(1) = 1

    4. D.

      T(n)=T(n−1)+n 𝑇(1) = 1

    Correct answer: A, B

    Solution

    To determine the time complexity, we analyze each recurrence relation individually.

    Option A: T(n) = T(n-1) + 1. Expanding this gives T(n) = T(1) + (n-1). Since T(1) is constant, the complexity is Theta(n).

    Option B: T(n) = 2T(n/2) + 1. Using the Master Theorem, a=2, b=2, f(n)=1. Since n^log_b a = n dominates f(n), the complexity is Theta(n).

    Option C: T(n) = 2T(n/2) + n. Here a=2, b=2, f(n)=n. Since f(n) matches n^log_b a, the complexity is Theta(n log n).

    Option D: T(n) = T(n-1) + n. This sums integers from 1 to n, resulting in a quadratic complexity of Theta(n^2).

    Conclusion: Options A and B correspond to an algorithm with time complexity Theta(n).

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  25. Q25.GATE 2026

    Let R be a binary relation on the set {1,2,…,10}, where (x,y)∈R if the product of x andy is a perfect square.
    Which of the following properties are satisfied by R?

    1. A.

      Reflexive

    2. B.

      Symmetric

    3. C.

      Transitive

    4. D.

      Antisymmetric

    Correct answer: A, B, C

    Solution

    Given a binary relation R on the set {1, 2, ..., 10} where (x, y) ∈ R if x * y is a perfect square.

    Reflexive: For any x, x * x = x^2, which is always a perfect square. Thus, (x, x) ∈ R for all x. The relation is Reflexive.

    Symmetric: If x * y is a square, then y * x is the same product and also a square. Thus, (x, y) ∈ R implies (y, x) ∈ R. The relation is Symmetric.

    Transitive: If x * y = a^2 and y * z = b^2, then (x * y) * (y * z) = (ab)^2. Dividing by y^2 gives x * z = (ab/y)^2. Since x, y, z are integers, x * z is a square. The relation is Transitive.

    Antisymmetric: Consider x = 2 and y = 8. x * y = 16 (square), so (2, 8) ∈ R. Also (8, 2) ∈ R. Since 2 ≠ 8, the relation is not Antisymmetric.

    Conclusion: The relation R satisfies Reflexive, Symmetric, and Transitive properties.

    Practice this question →

  26. Q26.GATE 2026

    For a real number a, let

    image.png

    Which of the following statements are true?

    1. A.

      The value of I(a) is independent of the value of a

    2. B.

      The value of I(a) can vary with the value of a

    3. C.

      There exists a such that I(a) is positive

    4. D.

      There exists a such that I(a) is negative

    Correct answer: A, C

    Solution

    I(a) = ∫ from -1 to 1 (3x² - ax + 1) dx. Split the integral: ∫3x² dx - a∫x dx + ∫1 dx over [-1, 1]. The middle term is 0 because x is an odd function on a symmetric interval. Therefore I(a) = [x³] from -1 to 1 + [x] from -1 to 1 = (1 - (-1)) + (1 - (-1)) = 2 + 2 = 4. Hence I(a) is independent of a and is always positive. The true statements are options 1 and 3.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  27. Q27.GATE 2026

    In a system, numbers are represented using 4-bit two’s complement form.
    N1​=1011, N2​=1101, N3​=1010, N4​=1001
    Which of the following operations will result in arithmetic overflow?

    1. A.

      N1+N2

    2. B.

      N2+N3

    3. C.

      N3−N4

    4. D.

      N1+N4

    Correct answer: B, D

    Solution

    Step-by-Step Analysis

    First, convert the 4-bit two's complement numbers to decimal to determine their values. The range for 4-bit two's complement is -8 to +7.

    N1 = 1011: Invert bits (0100) + 1 = 0101 (5). Since MSB is 1, value is -5.

    N2 = 1101: Invert bits (0010) + 1 = 0011 (3). Since MSB is 1, value is -3.

    N3 = 1010: Invert bits (0101) + 1 = 0110 (6). Since MSB is 1, value is -6.

    N4 = 1001: Invert bits (0110) + 1 = 0111 (7). Since MSB is 1, value is -7.

    Evaluate Each Operation

    Option A (N1 + N2): -5 + (-3) = -8. This is within the range [-8, +7]. No overflow.

    Option B (N2 + N3): -3 + (-6) = -9. This is less than -8. Arithmetic overflow occurs.

    Option C (N3 - N4): -6 - (-7) = -6 + 7 = 1. This is within the range. No overflow.

    Option D (N1 + N4): -5 + (-7) = -12. This is less than -8. Arithmetic overflow occurs.

    Both Option B and Option D result in arithmetic overflow.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  28. Q28.GATE 2026

    Which of the following grammars are ambiguous?

    1. A.

      𝑆 → 𝑎𝑆𝑏 | epsilon

    2. B.

      E→ 𝐸 + 𝐸 | 𝐸 ∗ 𝐸 | 𝑖𝑑

    3. C.

      S→ 𝑎𝑆 | 𝑆𝑎 | epsilon

    4. D.

      S → 𝑎𝑆 | epsilon

    Correct answer: B, C

    Solution

    Analysis of Grammar Ambiguity

    A grammar is considered ambiguous if there exists at least one string that has more than one leftmost derivation or parse tree.

    Option A generates strings of the form an bn. Each string has a unique derivation sequence, making this grammar unambiguous.

    Option B allows multiple parse trees for expressions like id + id * id due to missing operator precedence rules. This creates ambiguity.

    Option C allows derivation of strings like 'aa' via left recursion (S -> aS -> aa) or right recursion (S -> Sa -> aa). This results in ambiguity.

    Option D generates strings of the form an. Each string length corresponds to a unique number of recursive steps, ensuring a single derivation tree.

    Conclusion: Options B and C are ambiguous grammars.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  29. Q29.GATE 2026

    The keys 5, 28, 19, 15, 26, 33, 12, 17, 10 are inserted into a hash table using the hash function:

    h(k)=k mod 9

    Collisions are resolved by chaining.

    After all keys are inserted, the length of the longest chain is:

    Correct answer: 3

    Solution

    Hash Table Chain Analysis

    Given hash function: h(k) = k mod 9

    Step 1: Calculate hash values for each key

    • 5 mod 9 = 5

    • 28 mod 9 = 1

    • 19 mod 9 = 1

    • 15 mod 9 = 6

    • 26 mod 9 = 8

    • 33 mod 9 = 6

    • 12 mod 9 = 3

    • 17 mod 9 = 8

    • 10 mod 9 = 1

    Step 2: Build chains at each index

    • Index 0: (empty)

    • Index 1: 28 → 19 → 10 (length = 3)

    • Index 2: (empty)

    • Index 3: 12 (length = 1)

    • Index 4: (empty)

    • Index 5: 5 (length = 1)

    • Index 6: 15 → 33 (length = 2)

    • Index 7: (empty)

    • Index 8: 26 → 17 (length = 2)

    Step 3: Find maximum chain length

    The longest chain is at index 1 with length 3.

    Answer: 3

    Practice this question →

  30. Q30.GATE 2026

    Consider the system of linear equations:

    ax+y=b
    16x+ay=24

    Suppose the values of a and b are chosen such that the system produces multiple solutions.

    The product of a and b is:

    Correct answer: 24

    Solution

    For a system of linear equations to have multiple (infinite) solutions, the ratios of corresponding coefficients must be equal.

    Given: ax + y = b and 16x + ay = 24. Condition: a/16 = 1/a = b/24.

    From a/16 = 1/a, we get a^2 = 16, so a = ±4. From 1/a = b/24, we get b = 24/a.

    Product ab = a * (24/a) = 24. Thus, the product of a and b is 24.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  31. Q31.GATE 2026

    Consider the array:

    A=[10,7,8,19,41,35,25,31]

    Suppose merge sort is executed to sort the array in increasing order.
    The algorithm performs 7 merge operations.

    A merge is called void if the output is simply elements of left array followed by elements of right array.
    The number of void merge operations is:

    Correct answer: 3

    Solution

    To find the number of void merge operations, we trace the Merge Sort algorithm on the array A = [10, 7, 8, 19, 41, 35, 25, 31].

    Step 1: Divide the Array

    The array is recursively divided until sub-arrays of size 1 are reached:

    • Level 0: [10, 7, 8, 19, 41, 35, 25, 31]

    • Level 1: [10, 7, 8, 19] and [41, 35, 25, 31]

    • Level 2: [10, 7], [8, 19], [41, 35], [25, 31]

    • Level 3 (Base): [10], [7], [8], [19], [41], [35], [25], [31]

    Step 2: Perform Merges (Bottom-Up)

    A merge is 'void' if the largest element of the left sub-array is less than or equal to the smallest element of the right sub-array. In this case, the output is just the left elements followed by the right elements.

    • Merge 1: [10] and [7]. Left max (10) > Right min (7). Result: [7, 10]. (Not void)

    • Merge 2: [8] and [19]. Left max (8) < Right min (19). Result: [8, 19]. (Void)

    • Merge 3: [41] and [35]. Left max (41) > Right min (35). Result: [35, 41]. (Not void)

    • Merge 4: [25] and [31]. Left max (25) < Right min (31). Result: [25, 31]. (Void)

    • Merge 5: [7, 10] and [8, 19]. Left max (10) > Right min (8). Result: [7, 8, 10, 19]. (Not void)

    • Merge 6: [35, 41] and [25, 31]. Left max (41) > Right min (25). Result: [25, 31, 35, 41]. (Not void)

    • Merge 7: [7, 8, 10, 19] and [25, 31, 35, 41]. Left max (19) < Right min (25). Result: [7, 8, 10, 19, 25, 31, 35, 41]. (Void)

    Step 3: Count Void Merges

    The void merges occurred in Merge 2, Merge 4, and Merge 7.

    Total void merge operations = 3.

    Practice this question →

  32. Q32.GATE 2026

    If an IP network uses the subnet mask:

    255.255.240.0

    The maximum number of IP addresses that can be assigned to network interfaces is:

    Correct answer: 4094

    Solution

    Step 1: Convert the subnet mask 255.255.240.0 to binary notation. The third octet 240 corresponds to 11110000 in binary.

    Step 2: Count the network bits. There are 8 + 8 + 4 = 20 network bits in total.

    Step 3: Determine the host bits. Subtract network bits from 32 total bits: 32 - 20 = 12 host bits.

    Step 4: Calculate total addresses. 2 raised to the power of 12 equals 4096 total addresses.

    Step 5: Calculate usable addresses. Subtract 2 reserved addresses (network and broadcast) from the total: 4096 - 2 = 4094.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  33. Q33.GATE 2026

    The 32-bit IEEE 754 single precision representation of a number is:

    0xC2710000

    The number in decimal representation (rounded to two decimal places) is:

    Correct answer: -60.25

    Solution

    Step-by-Step Conversion

    The given 32-bit IEEE 754 single precision hexadecimal value is 0xC2710000.

    First, convert the hexadecimal value to binary:

    C = 1100, 2 = 0010, 7 = 0111, 1 = 0001, 0 = 0000, 0 = 0000, 0 = 0000, 0 = 0000

    Binary: 1100 0010 0111 0001 0000 0000 0000 0000

    Break down the 32 bits into Sign (1 bit), Exponent (8 bits), and Mantissa (23 bits):

    Sign bit: 1 (Negative number)

    Exponent bits: 10000100

    Mantissa bits: 11100010000000000000000

    Calculate the actual exponent:

    Exponent (binary) = 10000100 = 128 + 4 = 132

    Actual Exponent = 132 - 127 (bias) = 5

    Calculate the significand (Mantissa + 1):

    Mantissa = 1.1110001 (binary)

    Convert to decimal: 1 + 1/2 + 1/4 + 1/8 + 1/128 = 1 + 0.5 + 0.25 + 0.125 + 0.0078125 = 1.8828125

    Final Calculation:

    Value = (-1)^Sign × Significand × 2^Actual Exponent

    Value = -1 × 1.8828125 × 2^5

    Value = -1 × 1.8828125 × 32

    Value = -60.25

    The decimal representation rounded to two decimal places is -60.25.

    Practice this question →

  34. Q34.GATE 2026

    A lexical analyzer uses the following token definitions:

    image.png

    For the string given below,

    𝑥1 23𝑚𝑚 78 𝑦 7𝑧 𝑧𝑧5 14𝐴 8𝐻 𝐴𝑎𝑌𝑐𝐷

    the number of tokens (excluding 𝑤𝑠) that will be produced by the lexical analyzer is_____________.

    Correct answer: 13

    Solution

    To find the number of tokens, we parse the input string from left to right using the given grammar rules.
    Rules: id starts with a letter, number starts with a digit.
    x1 -> id
    23 -> number
    mm -> id
    78 -> number
    y -> id
    7 -> number
    z -> id
    zz5 -> id
    14 -> number
    A -> id
    8 -> number
    H -> id
    AaYcD -> id
    Total number of tokens = 13.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  35. Q35.GATE 2026

    Consider a complete graph 𝐾𝑛 with 𝑛 vertices (𝑛 > 4). Note that multiple spanning trees can be constructed over 𝐾𝑛. Each of these spanning trees is represented as a set of edges. The Jaccard coefficient between any two sets is defined as the ratio of the size of the intersection of the two sets to the size of the union of the two sets. Which one of the following options gives the lowest possible value for the Jaccard coefficient between any two spanning trees of 𝐾𝑛 ?

    1. A.

      1/n

    2. B.

      1/(2n-3)

    3. C.

      0

    4. D.

      1/(n-1)

    Correct answer: C

    Solution

    Step 1: A spanning tree of a complete graph K_n with n vertices contains exactly n-1 edges.

    Step 2: The Jaccard coefficient between two sets of edges E1 and E2 is defined as |E1 ∩ E2| / |E1 ∪ E2|.

    Step 3: To minimize the coefficient, we must minimize the intersection size |E1 ∩ E2|.

    Step 4: For n > 4, the complete graph K_n contains at least two edge-disjoint spanning trees.

    Step 5: If two spanning trees are edge-disjoint, their intersection size is zero. This results in a Jaccard coefficient of 0 / (2n - 2) = 0.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  36. Q36.GATE 2026

    Let 𝐺 be a weighted directed acyclic graph with 𝑚 edges and 𝑛 vertices. Given 𝐺 and a source vertex 𝑠 in 𝐺, which one of the following options gives the worst case time complexity of the fastest algorithm to find the lengths of shortest paths from 𝑠 to all vertices that are reachable from 𝑠 in 𝐺?

    1. A.

      Θ(m+n)

    2. B.

      Θ(m+nlog⁡n)

    3. C.

      Θ(nm)

    4. D.

      Θ(n3)

    Correct answer: A

    Solution

    Shortest Path in Directed Acyclic Graph

    For a weighted Directed Acyclic Graph (DAG), the shortest paths from a single source can be found efficiently using a combination of topological sorting and edge relaxation.

    Algorithm Steps

    1. Compute the topological sort of the graph vertices.

    2. Initialize distances from the source to infinity, except source distance is zero.

    3. Process vertices in topological order and relax all outgoing edges.

    Time Complexity Analysis

    Topological sorting takes O(V + E) time. Relaxing all edges also takes O(V + E) time. Therefore, the total worst-case time complexity is O(V + E), which is linear.

    Practice this question →

  37. Q37.GATE 2026

    Consider an array 𝐴 of integers of size 𝑛. The indices of 𝐴 run from 1 to 𝑛. An algorithm is to be designed to check whether 𝐴 satisfies the condition given below
    ∀𝑖,𝑗 ∈ {1, … , 𝑛 − 1} such that 𝑖 > 𝑗, (𝐴[𝑖 + 1] − 𝐴[𝑖]) > (𝐴[𝑗 + 1] − 𝐴[𝑗])
    Which one of the following gives the worst case time complexity of the fastest algorithm that can be designed for the problem?

    1. A.

      Θ(n)

    2. B.

      Θ(log⁡n)

    3. C.

      Θ(nlog⁡n)

    4. D.

      Θ(n2)

    Correct answer: A

    Solution

    The given condition requires checking if the difference between consecutive elements is strictly increasing for all valid indices.

    Let D[i] = A[i+1] - A[i]. The condition becomes D[i] > D[j] for all i > j, which implies the sequence D must be strictly increasing.

    We can compute all D values and verify the increasing order in a single pass through the array. This involves O(n) operations to calculate differences and O(n) to check the order.

    Thus, the total time complexity is Θ(n), as we only need to traverse the array once to validate the property.

    Practice this question →

  38. Q38.GATE 2026

    Consider a table 𝑇, where the elements 𝑇[𝑖][𝑗], 0 ≤ 𝑖,𝑗 ≤ 𝑛, represent the cost of the optimal solutions of different subproblems of a problem that is being solved using a dynamic programming algorithm. The recursive formulation to compute the table entries is as follows:
    𝑇[0][𝑘] = 𝑇[𝑘][0] = 1 for 𝑘 = 0,1,2, … , 𝑛
    𝑇[𝑖][𝑗] = 2𝑇[𝑖 − 1][𝑗] + 3𝑇[𝑖][𝑗 − 1] for 1 ≤ 𝑖,𝑗 ≤ n
    Consider the following two algorithms to compute entries of 𝑇. Assume that for both the algorithms, for all 0 ≤ 𝑖,𝑗 ≤ 𝑛, 𝑇[𝑖][𝑗] has been initialized to 1.
    Algorithm 𝐵1: For 𝑖 = 1, 2, … , 𝑛
    For 𝑗 = 1, 2, … , 𝑛
    𝑇[𝑖][𝑗] = 2𝑇[𝑖 − 1][𝑗] + 3𝑇[𝑖][𝑗 − 1]

    Algorithim B2 :for S:2,3......2n
    For 𝑖 = 1, 2, … , 𝑛
    For 𝑗 = 1, 2, … , 𝑛
    If (𝑖 + 𝑗 == 𝑠)
    𝑇[𝑖][𝑗] = 2𝑇[𝑖 − 1][𝑗] + 3𝑇[𝑖][𝑗 − 1]

    Algorithm 𝐵𝑘, 𝑘 ∈ {1,2} is said to be correct if and only if it calculates the correct values of 𝑇[𝑖][𝑗], for all 0 ≤ 𝑖,𝑗 ≤ 𝑛, (as per the recursive formulation) at the end of the execution of the algorithm 𝐵𝑘.
    Which one of the following statements is true?

    1. A.

      Both algorithms B1 and B2 are correct

    2. B.

      Algorithm B1 correct, B2 incorrect

    3. C.

      Algorithm B2 correct, B1 incorrect

    4. D.

      Both incorrect

    Correct answer: A

    Solution

    The recurrence relation depends on T[i-1][j] and T[i][j-1]. Both algorithms must ensure these values are computed before T[i][j].

    Algorithm B1 iterates i from 1 to n, then j from 1 to n. When computing T[i][j], T[i-1][j] is from the previous row (already computed) and T[i][j-1] is from the current row (already computed). Thus, B1 is correct.

    Algorithm B2 iterates S from 2 to 2n. Dependencies T[i-1][j] and T[i][j-1] have index sums S-1. Since S increases, values for S-1 are computed before S. Thus, B2 is also correct.

    Conclusion: Both algorithms respect the dependency structure and compute the table correctly.

    Practice this question →

  39. Q39.GATE 2026

    Consider the Boolean function:

    F(A,B,C,D)=Σm(0,1,2,3,8,9,10,11)

    where A is MSB and D is LSB.

    What is the minimal sum-of-products form?

    1. A.

      A′+B′+C′+D′

    2. B.

      B′

    3. C.

      A′B′+AB

    4. D.

      A′

    Correct answer: B

    Solution

    The given Boolean function is F(A,B,C,D) = Σm(0,1,2,3,8,9,10,11).

    Convert minterms to binary (A is MSB, D is LSB):

    0: 0000, 1: 0001, 2: 0010, 3: 0011, 8: 1000, 9: 1001, 10: 1010, 11: 1011

    Group 1 (0,1,2,3): A=0, B=0. Term: A'B'

    Group 2 (8,9,10,11): A=1, B=0. Term: AB'

    Combine terms: A'B' + AB' = B'(A' + A) = B'

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  40. Q40.GATE 2026

    Consider the canonical LR(0) parsing of the grammar:

    image.png

    Which one of the following options gives the number of shift-reduce conflicts that will occur in the 𝐿𝑅(0) ACTION table?

    1. A.

      2

    2. B.

      3

    3. C.

      4

    4. D.

      5

    Correct answer: D

    Solution

    Construct the LR(0) item sets and count the states that contain both a completed item, which gives a reduce action, and an item that shifts a terminal.

    1. For A → aA | ε, the initial state and the state reached after shifting a both contain A → · and also have a shift on a. This gives 2 shift-reduce conflicts.
    2. After A is recognized, the analogous C states contain C → · and also have a shift on c. This gives 2 more shift-reduce conflicts.
    3. For B → bB | b, the state reached after shifting b contains B → b · as a reduce item and also has a shift on b from B → · bB / B → · b. This gives 1 more shift-reduce conflict.

    Total conflicts = 2 + 2 + 1 = 5.
    Therefore, option D is correct.

    Practice this question →

  41. Q41.GATE 2026

    In the context of schema normalization in relational DBMS, consider a set F of functional dependencies. The set of all functional dependencies implied by F is called the closure of F. To compute the closure of F, Armstrong’s Axioms can be applied. Consider 𝑋, 𝑌, and 𝑍 as sets of attributes over a relational schema. The three rules of Armstrong’s Axioms are described as follows
    Reflexivity: If 𝑌 ⊆ 𝑋 , then 𝑋 → 𝑌
    Augmentation: If 𝑋 → 𝑌, then 𝑋𝑍 → 𝑌𝑍 for any Z
    Transitivity: If 𝑋 → 𝑌 and 𝑌 → 𝑍, then 𝑋 → Z
    The additional rule of Union is defined as follows.
    Union: If 𝑋 → 𝑌 and 𝑋 → 𝑍, then 𝑋 → 𝑌𝑍

    It can be proved that the additional rule of Union is also implied by the three rules of Armstrong’s Axioms. Listed below are four combinations of these three rules. Which one of these combinations is both necessary and sufficient for the proof ?

    1. A.

      Reflexivity, Augmentation, and Transitivity

    2. B.

      Reflexivity and Augmentation

    3. C.

      Transitivity

    4. D.

      Augmentation and Transitivity

    Correct answer: D

    Solution

    The correct answer is Option D: Augmentation and Transitivity.

    Proof of Union Rule:

    Given:
    X → Y
    X → Z

    Step 1:
    From X → Y, apply Augmentation with X:

    XX → XY

    Since XX = X,

    X → XY

    Step 2:
    From X → Z, apply Augmentation with Y:

    XY → YZ

    Step 3:
    Using Transitivity on:

    X → XY
    XY → YZ

    We get:

    X → YZ

    Thus, the Union rule is derived using only:

    • Augmentation

    • Transitivity

    Reflexivity is not required in this proof.

    Hence, the correct answer is Option D.

    Practice this question →

  42. Q42.GATE 2026

    Consider the transmission of data bits 110001011 over a link that uses Cyclic Redundancy Check (CRC) code for error detection. If the generator bit pattern is given to be 1001, which one of the following options shows the remainder bit pattern appended to the data bits before transmission?

    1. A.

      011

    2. B.

      101

    3. C.

      000

    4. D.

      100

    Correct answer: D

    Solution

    Generator polynomial: 1001
    Degree = 3 → append 3 zeros to the data.

    Data bits:
    110001011 → 110001011000

    Now perform mod-2 division of 110001011000 by 1001.

    After XOR divisions, the remainder obtained = 100.

    So the CRC bits appended to the data = 100.

    Final transmitted bit pattern:
    110001011100

    ✔ Answer: 100 (remainder appended).

    Practice this question →

  43. Q43.GATE 2026

    Consider a processor with 16 general-purpose registers and a 2-byte instruction format for every instruction. Variable-sized prefix opcodes are permitted. There are three instruction types: M-type, R-type, and C-type. Each M-type instruction has two register operands and a 6-bit immediate operand. Each R-type instruction has three register operands. Each C-type instruction has one register operand and a 6-bit offset. If there are 2 unique M-type opcodes and 7 unique R-type opcodes, what is the maximum possible number of unique C-type opcodes?

    1. A.

      8

    2. B.

      4

    3. C.

      64

    4. D.

      16

    Correct answer: B

    Solution

    Concept

    For a fixed 16-bit instruction word with variable-length prefix opcodes, each opcode reserves every bit pattern formed by its operand fields. Therefore, the fractions of the instruction space occupied by all instruction classes must add to at most 1.

    If a class has k operand bits and n opcodes, it occupies n × 2k encodings out of 216. This is the prefix-space constraint expressed by the Kraft inequality.

    Application

    1. Each register number needs log2(16) = 4 bits.

    2. An M-type instruction has 2 × 4 + 6 = 14 operand bits. Its 2 opcodes occupy 2 × 214 = 32768 encodings.

    3. An R-type instruction has 3 × 4 = 12 operand bits. Its 7 opcodes occupy 7 × 212 = 28672 encodings.

    4. A C-type instruction has 4 + 6 = 10 operand bits. If N C-type opcodes are provided, they occupy N × 210 encodings.

    5. The total cannot exceed 216: 2 × 214 + 7 × 212 + N × 210216.

    6. Dividing by 210 gives 32 + 28 + N ≤ 64, so N ≤ 4. Therefore, the maximum number of C-type opcodes is 4.

    Cross-check

    Using opcode-prefix fractions directly: 2/22 + 7/24 + N/26 ≤ 1. Thus 1/2 + 7/16 + N/64 ≤ 1, which again gives N ≤ 4.

    Practice this question →

  44. Q44.GATE 2026

    Consider the control flow graph given below.

    image.png

    Which one of the following options is the set of live variables at the exit point of each basic block?

    1. A.

      B1:{a, b, c, e, f}, B2:{d, e}, B3:{b, c, e, f}, B4:∅

    2. B.

      B1:∅, B2:{d, e}, B3:{a, c, f}, B4:∅

    3. C.

      B1:{a, b, c, e, f}, B2:{d, e}, B3:{c, e, f}, B4:∅

    4. D.

      B1:∅, B2:{d, e, f}, B3:{a, b, c, e, f}, B4:∅

    Correct answer: A

    Solution

    Live Variable Analysis Solution

    We perform backward data flow analysis to find the set of live variables at the exit of each basic block (LiveOut). A variable is live at a point if its value is used along some path from that point to the exit.

    Step 1: Analyze Block B4

    Statement: g = d + e

    Uses: {d, e}, Defines: {g}

    Successor: Exit (no live variables)

    LiveOut(B4) = ∅

    LiveIn(B4) = Uses ∪ (LiveOut(B4) - Defines) = {d, e} ∪ (∅ - {g}) = {d, e}

    Step 2: Analyze Block B2

    Statement: d = a + e

    Uses: {a, e}, Defines: {d}

    Successor: B4

    LiveOut(B2) = LiveIn(B4) = {d, e}

    LiveIn(B2) = {a, e} ∪ ({d, e} - {d}) = {a, e}

    Step 3: Analyze Block B1 and B3 (Loop)

    Block B1: a = b + c. Uses: {b, c}, Defines: {a}. Successors: B2, B3.

    Block B3: e = a + f. Uses: {a, f}, Defines: {e}. Successor: B1.

    Equations:

    LiveOut(B1) = LiveIn(B2) ∪ LiveIn(B3) = {a, e} ∪ LiveIn(B3)

    LiveIn(B1) = {b, c} ∪ (LiveOut(B1) - {a})

    LiveIn(B3) = {a, f} ∪ (LiveIn(B1) - {e})

    Solving the system:

    1. LiveIn(B1) = {b, c} ∪ ({a, e} ∪ LiveIn(B3) - {a}) = {b, c, e} ∪ LiveIn(B3)

    2. Substitute LiveIn(B3): LiveIn(B1) = {b, c, e} ∪ {a, f} ∪ (LiveIn(B1) - {e})

    3. This implies LiveIn(B1) must contain {a, b, c, e, f}. Let's verify: LiveIn(B1) = {b, c, e, f}.

    If LiveIn(B1) = {b, c, e, f}, then LiveIn(B3) = {a, f} ∪ ({b, c, e, f} - {e}) = {a, b, c, f}.

    Then LiveOut(B1) = {a, e} ∪ {a, b, c, f} = {a, b, c, e, f}.

    Check consistency: LiveIn(B1) = {b, c} ∪ ({a, b, c, e, f} - {a}) = {b, c, e, f}. Consistent.

    Final Result

    LiveOut(B1) = {a, b, c, e, f}

    LiveOut(B2) = {d, e}

    LiveOut(B3) = LiveIn(B1) = {b, c, e, f}

    LiveOut(B4) = ∅

    Practice this question →

  45. Q45.GATE 2026

    An index in a DBMS is said to be dense if an index entry appears for every search-key value in the indexed file. Otherwise it is called a sparse index. Consider the following two statements.
    S1: A hash index must be a dense index
    S2: A 𝐵 + tree index can be a sparse index
    Which one of the following options is correct?

    1. A.

      Both S1 and S2 are true

    2. B.

      Both S1 and S2 are false

    3. C.

      S1 is true and S2 is false

    4. D.

      S1 is false and S2 is true

    Correct answer: A

    Solution

    A dense index contains an entry for every search-key value in the file, while a sparse index contains entries for only some values.

    Statement S1 is true because a hash index must map every search key to a bucket address to ensure retrieval, making it inherently dense.

    Statement S2 is true because B+ tree indexes can be implemented as either dense or sparse depending on the specific design requirements and data organization.

    Since both statements accurately describe the properties of their respective index types, the correct conclusion is that both S1 and S2 are true.

    Practice this question →

  46. Q46.GATE 2026

    Consider the following two finite automata 𝐷1 and 𝐷2

    image.png

    Which of the following statements is/are true?

    1. A.

      𝐿(𝐷1 ) = 𝐿(𝐷2 )

    2. B.

      L(𝐷1) is a proper subset of 𝐿(𝐷2 )

    3. C.

      𝐿(𝐷1 ) ∩ 𝐿(𝐷2 ) = { 𝜖}

    4. D.

      (𝐿(𝐷1 ) ∪ 𝐿(𝐷2)) consists of all strings in {0,1}whose length is divisible by 3

    Correct answer: C, D

    Solution

    Option A is false (languages differ).
    Example - 000 is accepted by D1 but not by D2

    Option B is false (D1 has strings not in D2).
    Example - 000 is in D1 but not in D2

    Option C is Correct1
    The intersection is just {ε}.

    Option D is true e.g., '100' has length 3 but is not in either language).

    Practice this question →

  47. Q47.GATE 2026

    Let Σ = {𝑎, 𝑏, 𝑐, 𝑑} and let 𝐿 = {𝑎 𝑖𝑏 𝑗 𝑐 𝑘𝑑 ∣ 𝑖,𝑗, 𝑘, ℓ ≥ 0}. Which of the following constraints ensure(s) that the language 𝐿 is context-free?

    1. A.

      i + 𝑘 = 𝑗 + ℓ

    2. B.

      𝑖 = 𝑘 and 𝑗 = ℓ

    3. C.

      i= ℓ and 𝑗 = k

    4. D.

      𝑖 + 𝑗 = 𝑘 + ℓ

    Correct answer: A, C, D

    Solution

    Analysis of Constraints

    The base language L = {a^i b^j c^k d^ℓ | i, j, k, ℓ ≥ 0} is regular. The context-free status depends on the constraints linking the counts.

    Option A: i + k = j + ℓ

    This constraint implies i - j = ℓ - k. A PDA can push for 'a' and 'c', and pop for 'b' and 'd'. State transitions handle stack underflow, making this language context-free.

    Option B: i = k and j = ℓ

    This requires matching 'a' with 'c' and 'b' with 'd' independently. The structure a^i b^j c^i d^j is not context-free because the stack cannot track two independent counts separated by other symbols.

    Option C: i = ℓ and j = k

    This forms a^i b^j c^j d^i. A PDA pushes 'a' and 'b', pops 'b' for 'c', and pops 'a' for 'd'. The nesting is valid, so this language is context-free.

    Option D: i + j = k + ℓ

    This balances the first half against the second half. A PDA pushes for 'a' and 'b', then pops for 'c' and 'd'. The linear relationship allows verification with a single stack.

    Conclusion

    Options A, C, and D ensure the language is context-free. Option B does not.

    Practice this question →

  48. Q48.GATE 2026

    Consider a binary search tree (BST) with 𝑛 leaf nodes (𝑛 > 0). Given any node 𝑉, the key present in the node is denoted as 𝑉𝑎𝑙(𝑉). All the keys present in the given BST are distinct. The keys belong to the set of real numbers. For a node 𝑉, let 𝑆𝑢𝑐(𝑉) denote the node that is its inorder successor. If a node 𝑉 does not have an inorder successor, then 𝑆𝑢𝑐(𝑉) is 𝑁𝑈𝐿𝐿. As there are no duplicates, if 𝑆𝑢𝑐(𝑉) is not 𝑁𝑈𝐿𝐿, then 𝑉𝑎𝑙(𝑉) < 𝑉𝑎𝑙(𝑆𝑢𝑐(𝑉)).

    Corresponding to every leaf node 𝐿𝑖 that has a non-NULL 𝑆𝑢𝑐(𝐿𝑖), a new key 𝑘𝑖 with the following property is to be inserted into the BST.
    𝑉𝑎𝑙(𝐿𝑖) < 𝑘𝑖 < 𝑉𝑎𝑙(𝑆𝑢𝑐(𝐿𝑖))
    Let 𝐾 represent the list of all such new keys to be inserted into the BST. Which of the following statements is/are true?

    1. A.

      K cannot have any duplicates

    2. B.

      K will have at least one element

    3. C.

      After inserting all keys from 𝐾, the height of the BST can increase at most by one

    4. D.

      Number of nodes in the BST will double after inserting all keys from K

    Correct answer: A, C

    Solution

    Core Idea

    For every leaf LiL_iLi​ with successor:

    Val(Li)<ki<Val(Suc(Li))\text{Val}(L_i) < k_i < \text{Val}(Suc(L_i))Val(Li​)<ki​<Val(Suc(Li​))

    So each new key lies strictly between two consecutive inorder elements

    Option A: K cannot have duplicates

    TRUE

    • Each kik_iki​ lies in a unique open interval between two consecutive keys

    • Intervals do not overlap
      So no two kik_iki​ can be equal

    Option B: K will have at least one element

    FALSE

    • If BST has only one node (also a leaf)

    • It has no successor
      No kik_iki​ generated

    • Option C: Height increases at most by one

    TRUE

    • Each kik_iki​ is inserted between a leaf and its successor

    • So it becomes child of that leaf
      Only extends leaf depth by 1

    Option D: Number of nodes doubles
    FALSE

    • New keys = number of leaves with successor

    • In skewed tree → only 1 such leaf
      Not doubling

    Final Answer:

    A and C

    Practice this question →

  49. Q49.GATE 2026

    Consider a stack 𝑆 and a queue 𝑄. Both of them are initially empty and have the capacity to store ten elements each. The elements 1, 2, 3, 4, and 5 arrive one by one, in that order. When an element arrives, it is assigned either to 𝑆 (pushed on 𝑆 ) or to 𝑄 (enqueued to 𝑄). Once all the five elements are stored, the output is generated in two steps. First, stack S is emptied by popping all elements. Then queue 𝑄 is emptied by dequeueing all elements. The output obtained by following this process is 4 3 1 2 5 .

    Given the output, the objective is to predict whether an element was assigned to 𝑆 or 𝑄.
    Which of the following options is/are possible valid assignment(s) of the elements?

    Note: In the options, the notation 𝑥𝑆 denotes that element 𝑥 was assigned to 𝑆 and 𝑦𝑄 denotes that element 𝑦 was assigned to 𝑄.

    1. A.

      1𝑆, 2𝑄, 3𝑆, 4𝑆, 5Q

    2. B.

      1𝑄, 2𝑄, 3𝑆, 4𝑆, 5Q

    3. C.

      1𝑄, 2𝑄, 3𝑄, 4𝑆, 5S

    4. D.

      1𝑆, 2𝑆, 3𝑆, 4𝑄, 5𝑄

    Correct answer: A, B

    Solution

    Step 1: Analyze Output Structure The output 4 3 1 2 5 is generated in two phases. First, Stack S is emptied (popped). Second, Queue Q is emptied (dequeued). Thus, 4 3 1 comes from S, and 2 5 comes from Q.

    Step 2: Analyze Stack S Stack is LIFO (Last In First Out). Output 4 3 1 means 4 was pushed last, then 3, then 1. So 1, 3, 4 must be in S.

    Step 3: Analyze Queue Q Queue is FIFO (First In First Out). Output 2 5 means 2 was enqueued first, then 5. So 2, 5 must be in Q.

    Step 4: Conclusion Valid assignment: 1S, 2Q, 3S, 4S, 5Q.

    Practice this question →

  50. Q50.GATE 2026

    Consider three processes P1, P2, and P3 running identical code, as shown in the pseudocode below. A and B are two binary semaphores initialized to 1 and 0, respectively. X is a shared variable initialized to 0. Each line in the pseudocode is executed atomically

    Pseudocode of P1, P2, and P3
    Wait(A);

    Print(*);

    X = X + 1;

    If (X == 2)

    {

    Print($);

    Signal(B);

    }

    Signal(A);

    Wait(B);

    Print(#);

    Signal(B);

    Assume that any of the three processes can start to execute first and context switching can happen between these processes at any arbitrary time and in any arbitrary order.
    Which of the following patterns is/are possible to be generated as an outcome of the execution of these three processes?

    1. A.

      **$*###

    2. B.

      **$#*##

    3. C.

      **$##*#

    4. D.

      ***$###

    Correct answer: A, B, C

    Solution

    Now check each option

    A: $###

    ✔ Possible

    • P1 → * (X=1)

    • P2 → * (X=2) → $

    • P3 runs later → prints *

    • then ###

    **B: $*###

    ✔ Possible

    • P1, P2 → **$

    • P3 → *

    • then ###

    **C: $##*#

    ✔ Possible (this is the tricky one)

    Sequence:

    • P1 → *

    • P2 → *$

    • P2 immediately continues → prints #

    • P2 signals → another #

    • P3 (delayed earlier) now runs → prints *

    • last #

    So * can appear between #

    **D: *$###

    ❌ NOT possible

    Why?

    • For this to happen:

      • 3 stars must happen before $

    • But $ occurs exactly at X == 2
      So it must appear immediately after 2nd star, not after 3rd

    Practice this question →

  51. Q51.GATE 2026

    Consider a system with a processor and a 4 KB direct mapped cache with block size of 16 bytes. The system has a 16 MB physical memory. Four words P, Q, R, and S are accessed by the processor in the same order 10 times. That is, there are a total of 40 memory references in the sequence P, Q, R, S, P, Q, R, S,…

    Assume that the cache memory is initially empty. The physical addresses of the words are given below (1 word =1 byte).

    P: 0x845B32, Q: 0x845B26, R: 0x845B36, S: 0x846B32
    Which of the following statements is/are true

    Note: 1K=210 and 1M=220

    1. A.

      Every access to P results in a cache miss

    2. B.

      Every access to R results in a cache hit

    3. C.

      Every access to Q results in a cache miss

    4. D.

      Except the first access to S, all subsequent accesses to S result in cache hits

    Correct answer: A, B

    Solution

    1. Cache Configuration Analysis

    Cache Size = 4 KB = 2^12 bytes. Block Size = 16 bytes = 2^4 bytes. Number of Cache Lines = 2^12 / 2^4 = 2^8 = 256 lines. Index Bits = log2(256) = 8 bits. Offset Bits = log2(16) = 4 bits. Physical Address = 16 MB = 2^24 bits. Tag Bits = 24 - 8 - 4 = 12 bits.

    2. Address Breakdown (Tag | Index | Offset)

    P: 0x845B32 -> Tag: 0x845 | Index: 0xB3 | Offset: 0x2 Q: 0x845B26 -> Tag: 0x845 | Index: 0xB2 | Offset: 0x6 R: 0x845B36 -> Tag: 0x845 | Index: 0xB3 | Offset: 0x6 S: 0x846B32 -> Tag: 0x846 | Index: 0xB3 | Offset: 0x2

    3. Access Sequence Analysis (Initially Empty Cache)

    Iteration 1: - P: Miss (Load 0xB3, Tag 0x845) - Q: Miss (Load 0xB2, Tag 0x845) - R: Hit (Index 0xB3, Tag 0x845 matches) - S: Miss (Index 0xB3, Tag 0x846 != 0x845). Evicts P. Iteration 2: - P: Miss (Index 0xB3, Tag 0x845 != 0x846). Evicts S. - Q: Hit (Index 0xB2, Tag 0x845) - R: Hit (Index 0xB3, Tag 0x845) - S: Miss (Index 0xB3, Tag 0x846 != 0x845). Evicts R.

    4. Conclusion

    P always misses due to conflict with S. Q hits after first access (unique index). R always hits (P loads block before R). S always misses due to conflict with P.

    Practice this question →

  52. Q52.GATE 2026

    To keep track of free blocks in a file system, one of the two approaches is generally used – using bitmaps (bit vectors) or using linked lists. Consider that the linked list approach is used to keep track of free blocks in a file system. Assume that the disk size is 16 GB, block size is 2 KB, and block numbers used are 32-bit long. A single pointer of size 4 bytes is used in each block of the list to point to the next block of the list. The number of blocks required to hold the free disk block numbers is __________________ .

    Correct answer: 16384

    Solution

    Step 1: Calculate the total number of blocks on the disk.

    Disk Size = 16 GB = 16 * 2^30 bytes.

    Block Size = 2 KB = 2 * 2^10 bytes.

    Total Number of Blocks = (16 * 2^30) / (2 * 2^10) = 8 * 2^20 = 8,388,608 blocks.

    Step 2: Calculate total space required for pointers.

    In a linked list approach, each block stores a pointer to the next free block.

    Pointer Size = 4 bytes.

    Total Pointer Space = 8,388,608 * 4 bytes.

    Step 3: Calculate blocks required to store pointers.

    Blocks Required = (Total Pointer Space) / Block Size

    = (8,388,608 * 4) / 2048 = 16,384 blocks.

    Final Answer: 16384

    Practice this question →

  53. Q53.GATE 2026

    A system has a Translation Lookaside Buffer (TLB) that has a reach of 1 MB. TLB reach is defined as the total amount of physical memory that can be accessed through the TLB entries. The paging system uses pages of size 4 KB. The virtual address space is 64 GB and physical address space is 1 GB. If each TLB entry stores a 4-bit process id, page number, frame number, and a 2-bit control field, then the size of the TLB (in bytes) is ___________. (answer in integer)

    Correct answer: 1536

    Solution

    First, calculate the number of TLB entries. TLB Reach is 1 MB and Page Size is 4 KB. Number of Entries = 1 MB / 4 KB = 256 entries.

    Next, determine the bits required per entry. PID is 4 bits. Control field is 2 bits.

    Page Number (VPN) bits: Virtual Address Space is 64 GB (2^36). Offset is 12 bits (4 KB). VPN = 36 - 12 = 24 bits.

    Frame Number (PFN) bits: Physical Address Space is 1 GB (2^30). Offset is 12 bits. PFN = 30 - 12 = 18 bits.

    Total bits per entry = 4 (PID) + 24 (VPN) + 18 (PFN) + 2 (Control) = 48 bits.

    Total TLB Size = 256 entries * 48 bits = 12288 bits. Convert to bytes: 12288 / 8 = 1536 bytes.

    Practice this question →

  54. Q54.GATE 2026

    Consider contiguous allocation of physical memory to processes using variable partitioning scheme. Suppose there are 8 holes in the memory of sizes 20 KB, 4 KB, 25 KB, 18 KB, 7 KB, 9 KB, 15 KB, and 12 KB. Assume that no two holes are adjacent. Two processes P1 of size 16 KB and P2 of size 9 KB arrive in that order, and they are allocated memory using the best-fit technique. After allocating space to P1 and P2, the number of holes of size less than 8 KB is ____________. (answer in integer)

    Correct answer: 3

    Solution

    Step-by-Step Best-Fit Allocation

    Initial holes: 20 KB, 4 KB, 25 KB, 18 KB, 7 KB, 9 KB, 15 KB, 12 KB.

    Process P1 (16 KB): Find the smallest hole >= 16 KB.

    • Candidates: 20 KB, 25 KB, 18 KB.

    • Best fit is 18 KB.

    Remaining hole from 18 KB: 18 - 16 = 2 KB.

    Current holes: 20 KB, 4 KB, 25 KB, 2 KB, 7 KB, 9 KB, 15 KB, 12 KB.

    Process P2 (9 KB): Find the smallest hole >= 9 KB.

    • Candidates: 20 KB, 25 KB, 9 KB, 15 KB, 12 KB.

    • Best fit is exactly 9 KB.

    Remaining hole from 9 KB: 9 - 9 = 0 KB (hole disappears).

    Final holes: 20 KB, 4 KB, 25 KB, 2 KB, 7 KB, 15 KB, 12 KB.

    Count holes with size < 8 KB: 4 KB, 2 KB, 7 KB.

    Total count = 3.

    Practice this question →

  55. Q55.GATE 2026

    Consider a system with 1 MB physical memory and a word length of 1 byte. The system uses a direct mapped cache with a block (cache line) size of 64 bytes, with block numbers starting from 0. The word with physical address 0xA2C28 is mapped to the cache block number 176. The maximum possible size of the cache (in KB) for this configuration is ___________. (answer in integer)
    Note: 1K=210 and 1M=220

    Correct answer: 128

    Solution

    In a direct-mapped cache, a byte-addressable physical address splits into a TAG field, a BLOCK-INDEX field, and a BLOCK-OFFSET field. The offset field has log2(block size) bits (here block size = 64 = 26 bytes, so 6 offset bits); the remaining higher-order bits form the block address. For a cache with N = 2k blocks, the block index of any address equals its BLOCK ADDRESS (address ÷ block size, integer division) taken modulo N -- which, since N is a power of two, is exactly the value formed by the block address's lowest k bits.

    So the same block index survives as k grows only as long as each newly-included bit of the block address (bit k, k+1, ...) is 0; the moment a 1-bit is included, the index changes. The "maximum possible cache size" is therefore the largest N = 2k for which the block address's low k bits still equal the given block index -- i.e. up to (but not including) the next 1-bit above that index's own bits.

    Application:

    1. Convert the physical address to decimal: 0xA2C28 = 10×164 + 2×163 + 12×162 + 2×16 + 8 = 655360 + 8192 + 3072 + 32 + 8 = 666,664.

    2. With a 64-byte block, the block address = ⌊666,664 ÷ 64⌋ = 10,416 (the low 6 bits of the physical address, 6 bits of 40 = 101000, form the byte-within-block offset and are dropped).

    3. Write 10,416 in binary: 10,416 = 101000101100002 (14 bits), i.e. its 1-bits sit at positions 13, 11, 7, 5 and 4 (bit 0 = least significant).

    4. For a cache with N = 2k blocks, the block index equals the block address's lowest k bits. Taking the lowest 8, 9, 10 or 11 bits of 10,416 all give the SAME value, 176 (= 101100002 = bits 4, 5 and 7 set), because block-address bits 8, 9 and 10 are all 0 -- it only changes at k = 12, where bit 11 (which is 1) enters and pushes the value up to 176 + 2048 = 2224.

    5. So the largest k for which the block index stays 176 is k = 11, giving the maximum cache size N = 211 = 2,048 blocks.

    6. With block size 64 bytes, cache size = 2,048 × 64 = 131,072 bytes. In KB (1K = 210): 131,072 ÷ 1024 = 128 KB.

    Cross-check:

    10,416 mod 2,048 = 176, which matches the given block index. Taking one more index bit (N = 212 = 4,096 blocks = 256 KB) would instead give block index 2,224 (not 176), confirming 131,072 bytes (128 KB) is indeed the maximum cache size consistent with this mapping.

    Final answer: 128 KB.

    Practice this question →

  56. Q56.GATE 2026

    Consider a new TCP connection between a sender and a receiver. The receiver advertised window is constant at 48 KB, the maximum segment size (MSS) is 2 KB, and the slow start threshold for TCP congestion control is 16 KB. Assume that there are no timeouts or duplicate acknowledgements. The number of rounds of transmission required for the congestion control algorithm of the TCP connection to reach the congestion avoidance phase is ___________. (answer in integer)

    Correct answer: 4

    Solution

    Given:

    • MSS = 2 KB → initial cwnd = 1 MSS = 2 KB

    • ssthresh = 16 KB

    Slow start growth (doubling each round):

    • Start: cwnd = 2 KB

    • After Round 1: cwnd = 4 KB

    • After Round 2: cwnd = 8 KB

    • After Round 3: cwnd = 16 KB

    Now the key detail
    TCP enters congestion avoidance after completing the round where cwnd reaches ssthresh.

    So:

    • Round 1 → sending with 2 KB

    • Round 2 → sending with 4 KB

    • Round 3 → sending with 8 KB

    • Round 4 → sending with 16 KB (ssthresh)

    • Congestion avoidance starts after Round 4 begins transmission

    Correct Answer:

    4

    Your answer is correct.

    Practice this question →

  57. Q57.GATE 2026

    A non-pipelined instruction execution unit that operates at 1.6 GHz clock takes an average of 5 clock cycles to complete the execution of an instruction. To improve the performance, the system was pipelined with a goal of achieving an average throughput of one instruction per clock cycle. However, it could operate only at 1.2 GHz due to pipeline overheads. While executing a program in the pipelined design, 30% of instructions encountered a stall of 2 cycles due to pipeline hazards. The speed-up obtained by the pipelined design over the non-pipelined one for this program is ___________

    Correct answer: 2.3 to 2.4

    Solution

    Step 1: Calculate execution time for non-pipelined design. Time = Cycles × (1 / Frequency) = 5 × (1 / 1.6 GHz).

    Step 2: Calculate execution time for pipelined design. Effective Cycles = 1 + (0.30 × 2) = 1.6. Time = 1.6 × (1 / 1.2 GHz).

    Step 3: Calculate Speed-up. Speed-up = Time_non-pipelined / Time_pipelined = (5/1.6) / (1.6/1.2) = 2.34375.

    Practice this question →

  58. Q58.GATE 2026

    Consider the digital circuit shown below with two input lines A and B, two select lines S0 and S1, and an output line Y. The blocks Q and M represent active high 2:4 decoder and 4-to-1 multiplexer, respectively. Out of 16 possible input combinations, the number of combinations that produce Y=1 is ____________. (answer in integer) Note: One input combination is an instance of [A B S1 S0]

    image.png

    Correct answer: 6

    Solution

    First, analyze the 2:4 Decoder (Q). With inputs A and B, the output D0 is high (1) when A=0 and B=0. The output D3 is high (1) when A=1 and B=1.

    Next, analyze the 4-to-1 Multiplexer (M). The select lines are S1 and S0. The inputs are: I0=D0, I1=0, I2=1, I3=D3.

    The output Y depends on S1 and S0 as follows:

    - If S1=0, S0=0, Y selects I0 (D0). Y=1 when A=0, B=0. (1 combination)

    - If S1=0, S0=1, Y selects I1 (0). Y is always 0. (0 combinations)

    - If S1=1, S0=0, Y selects I2 (1). Y is always 1 regardless of A and B. (4 combinations)

    - If S1=1, S0=1, Y selects I3 (D3). Y=1 when A=1, B=1. (1 combination)

    Total combinations where Y=1: 1 + 0 + 4 + 1 = 6.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  59. Q59.GATE 2026

    Consider the following ANSI-C program.

    image.png

    Correct answer: 9

    Solution

    Code Execution Trace

    1. Initialization: a = 5, b = 11, c = 20.

    2. ptr = &a; The pointer ptr now holds the address of variable a.

    3. *ptr = c; Since ptr points to a, this updates a to the value of c (20). Now a = 20.

    4. ptr = &c; The pointer ptr is updated to hold the address of variable c.

    5. a = *(&b); The address of b is taken and dereferenced, assigning the value of b (11) to a. Now a = 11.

    6. c = *ptr - a; ptr points to c, so *ptr is 20. a is 11. Calculation: c = 20 - 11 = 9.

    7. printf("%d", c); The program prints the final value of c, which is 9.

    Practice this question →

  60. Q60.GATE 2026

    Consider the following ANSI-C function.

    image.png

    The maximum possible value that can be returned from this function is ____________. (answer in integer)

    Correct answer: 1

    Solution

    To find the maximum return value, we analyze how the 'length' variable changes in each recursive call.

    1. If length % 3 == 0: length decreases by 1 (start increases by 1).

    2. If length % 3 == 1: length decreases by 1 (end decreases by 1), and 1 is added to the result.

    3. If length % 3 == 2: length decreases by 2 (start increases by 2).

    Notice the cycle of remainders modulo 3:

    - From 1 mod 3, we go to 0 mod 3 (add 1).

    - From 0 mod 3, we go to 2 mod 3 (subtract 1).

    - From 2 mod 3, we go to 0 mod 3 (subtract 2).

    Once the length is not congruent to 1 mod 3, it enters a cycle between 0 and 2, never returning to 1. Thus, the value '1' is added at most once.

    The maximum possible value is 1.

    Practice this question →

  61. Q61.GATE 2026

    The determinant of a 4 × 4 matrix A is 3. The value of the determinant of 2A is ____________. (answer in integer)

    Correct answer: 48

    Solution

    For an n × n matrix A, det(kA) = kⁿ det(A). Here n = 4 and k = 2. Hence, det(2A) = 2⁴ det(A) = 16 × 3 = 48. Therefore, the required integer answer is 48.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  62. Q62.GATE 2026

    Suppose an unbiased coin is tossed 6 times. Each coin toss is independent of all previous coin tosses. Let 𝐸1 be the event that among the second, fourth, and sixth coin tosses, there are at least two heads. Let 𝐸2 be the event that among the first, second, third, and fifth coin tosses, there are equal number of heads and tails. The conditional probability P(𝐸1 | 𝐸2) is equal to ____________. (rounded off to one decimal place)

    Correct answer: 0.5

    Solution

    Let the tosses be numbered 1 to 6. Event E2 says that among tosses 1, 2, 3 and 5 there are exactly two heads.

    By symmetry under E2, toss 2 is still equally likely to be H or T, so P(toss 2 is H | E2) = 1/2. Tosses 4 and 6 are independent of E2 and remain fair coin tosses.

    Therefore, under E2, the three tosses relevant to E1, namely tosses 2, 4 and 6, behave like three independent fair tosses. The probability of at least two heads among three fair tosses is:

    C(3,2)/2^3 + C(3,3)/2^3 = 3/8 + 1/8 = 4/8 = 0.5.

    Thus P(E1 | E2) = 0.5, rounded to one decimal place.

    Practice this question →

  63. Q63.GATE 2026

    Consider a function 𝑓: (0,1) → {0, 1} defined as follows. For a real number 𝑟 ∈ (0,1) , 𝑓(𝑟) = 1 if the second digit after the decimal point in 𝑟 is one of the four digits 2, 3, 6 and 7. Otherwise, 𝑓(𝑟) is equal to 0. The number of points in (0,1) at which 𝑓 is discontinuous is ___________. (answer in integer)

    Correct answer: 40

    Solution

    Write a number r in (0, 1) as 0.d1d2d3... . The value of f depends only on the second digit d2.

    On every open interval (k/100, (k+1)/100), the first two decimal digits are fixed, so f is constant there. Therefore discontinuities can occur only at the boundary points k/100, where k = 1, 2, ..., 99.

    Across such a boundary, the second decimal digit changes from (k - 1) mod 10 on the left to k mod 10 on the right. The set for which f = 1 is {2, 3, 6, 7}. The function value changes exactly at the transitions
    1 -> 2, 3 -> 4, 5 -> 6, and 7 -> 8.

    Thus, in each block of ten hundredths there are 4 discontinuity points. There are 10 such blocks from 0.00 to 1.00, so the total number of discontinuities is 10 x 4 = 40.

    Practice this question →

  64. Q64.GATE 2026

    It is necessary to design a link-layer protocol between two hosts that are directly connected over a lossless link of length 3000 kilometers. Assume that the link bandwidth is 108 bits per second and that the propagation delay in the link is 5 nanoseconds per meter (that is, a signal takes 5 ns to travel each meter of the link). Every transmitted data byte is assigned a unique sequence number.

    Let 𝑁 be the minimum number of bits needed for the sequence number field in the protocol header such that

    i. the sequence numbers do not wrap around before 60 seconds, and

    ii. the maximum utilization of the link is achieved.

    The value of 𝑁 is ______. (answer in integer)

    Correct answer: 30

    Solution

    Concept

    For a sliding-window / Go-Back-N link protocol where every byte gets its own sequence number, the minimum sequence-number width N must satisfy TWO independent constraints at once:

    • No-wrap-around: the total distinct sequence numbers, 2N, must exceed the total bytes transmitted during the required no-wrap interval — Bandwidth × Time / 8.

    • Maximum utilization: the sequence-number space must be large enough to number every byte in flight during one round-trip time, i.e. 2N must cover the bandwidth-delay product — Bandwidth × RTT / 8, where RTT = 2 × propagation delay.

    Since both conditions must hold simultaneously, N is the LARGER of the two individually-required bit counts.

    Application

    1. Link parameters

    Link Length (L) = 3000 km = 3,000,000 meters

    Propagation delay per metre (v) = 5 ns/m = 5 × 10-9 s/m

    Propagation Delay (T_prop) = L × v = 3,000,000 × 5 × 10-9 = 0.015 seconds

    Bandwidth (B) = 108 bits per second

    2. Maximum-utilization condition

    Round Trip Time (RTT) = 2 × T_prop = 2 × 0.015 = 0.03 seconds

    Bandwidth-Delay Product (in bits) = B × RTT = 108 × 0.03 = 3,000,000 bits

    Bandwidth-Delay Product (in bytes) = 3,000,000 / 8 = 375,000 bytes

    So the window size W must be at least 375,000 bytes, meaning the sequence-number space (2N − 1) must be at least 375,000.

    219 = 524,288, which already exceeds 375,000 — so this condition alone needs only N = 19.

    3. No-wrap-around condition

    Total bytes transmitted in 60 seconds = (Bandwidth × Time) / 8 = (108 × 60) / 8 = 6,000,000,000 / 8 = 750,000,000 bytes

    So we need 2N > 750,000,000.

    • 229 = 536,870,912 (too small)

    • 230 = 1,073,741,824 (greater than 750,000,000)

    So this condition needs N = 30.

    4. Combine the two conditions

    N must satisfy BOTH conditions, so N = max(19, 30) = 30. The wrap-around requirement is the binding (dominant) constraint.

    Cross-check

    Verify N = 30 independently satisfies both requirements: 230 ≈ 1.074 × 109 bytes of sequence space, which is (a) greater than the 750,000,000 bytes sent in 60 seconds — no wrap — and (b) far greater than the 375,000-byte window needed for full utilization. A smaller value, N = 29, gives only 229 = 536,870,912 sequence numbers, which is less than 750,000,000 and would wrap around before 60 seconds — confirming 30 is the minimum.

    Final Answer

    The minimum number of bits N is 30.

    Practice this question →

  65. Q65.GATE 2026

    Which one of the following statements is equivalent to the following assertion?
    Turing machine 𝑀 decides the language 𝐿 ⊆ {0,1}

    1. A.

      Turing machine 𝑀 halts on all input strings in {0,1}*

    2. B.

      Turing machine 𝑀 accepts all input strings in 𝐿

    3. C.

      Turing machine 𝑀 rejects all input strings in {0,1} − L

    4. D.

      Turing machine 𝑀 accepts all input strings in 𝐿 and rejects all input strings in {0,1} − L

    Correct answer: D

    Solution

    A Turing machine M decides a language L if and only if it halts on all inputs.

    Specifically, for every input string w in the alphabet, M must halt and either accept or reject.

    If w is in L, M must accept. If w is not in L, M must reject.

    Option D captures both conditions: acceptance for strings in L and rejection for strings outside L.

    Practice this question →

  66. Q66.GATE 2026

    The antonym of the word protagonist is ________.

    1. A.

      agnostic

    2. B.

      antagonist

    3. C.

      arsonist

    4. D.

      anarchist

    Correct answer: B

    Solution

    The correct answer is:

    B) antagonist

    Explanation:

    • A protagonist is the main or central character in a story (usually the hero).

    • An antagonist is the character who opposes the protagonist (often the villain).

    Why others are incorrect:

    • Agnostic – someone unsure about religious beliefs

    • Arsonist – a person who sets fires

    • Anarchist – someone who opposes authority/government

    So, the antonym of protagonist is antagonist

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  67. Q67.GATE 2026

    The figure shows two 4-tile patterns.

    image.png

    Either one or both of the patterns can be used any number of times and in any orientation to construct a new pattern. Which one of the options below cannot be constructed by using only these two 4-tile patterns assuming there are no overlaps among them?

    Solution

    1. Analyze the building blocks: Both given patterns are composed of exactly 4 small square tiles.
    2. Establish the core rule: Any new figure constructed without overlapping these blocks must have a total tile count that is perfectly divisible by 4.
    3. Count the total tiles in each option: Option A = 2x4 (8 tiles), Option B = 3x4 (12 tiles), Option C = 3x5 (15 tiles), Option D = 4x5 (20 tiles).
    4. Since 15 is not a multiple of 4, Option C cannot be formed.

    Final Answer: Option C

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  68. Q68.GATE 2026

    Consider the following grammar where 𝑆 is the start symbol, and 𝑎 and 𝑏 are terminal symbols.

    𝑆→𝑎𝑆𝑏𝑆 ∣ 𝑏𝑆 ∣ ϵ

    Which of the following statements is/are true?

    1. A.

      The grammar is ambiguous

    2. B.

      The string 𝑎𝑏𝑏 has two distinct derivations in this grammar

    3. C.

      The string 𝑎𝑏𝑎𝑏 has only one rightmost derivation

    4. D.

      The language generated by the grammar is undecidable

    Correct answer: A, B, C

    Solution

    The grammar S → aSbS | bS | ε generates a Context-Free Language. To check for ambiguity, consider the string 'abb'. It admits two distinct derivations: S ⇒ aSbS ⇒ abS bS ⇒ abb and another structural variation, confirming the grammar is ambiguous (Options 0 and 1). For string 'abab', the derivation structure forces a unique rightmost path, validating Option 2. Since all Context-Free Languages are decidable, the claim regarding undecidability is false.

    Practice this question →

  69. Q69.GATE 2026

    Consider a system consisting of 𝑘 instances of a resource 𝑅, being shared by 5 processes. Assume that each process requires a maximum of two instances of resource 𝑅 and a process can request or release only one instance at a time. Further, a process can request the second instance of the resource only after acquiring the first instance. The minimum value of 𝑘 for the system to be deadlock-free is ________. (answer in integer)

    Correct answer: 6

    Solution

    Step-by-Step Solution

    To find the minimum value of k for the system to be deadlock-free, we first determine the maximum number of resources that can be held by the processes without causing a deadlock, and then add one more resource to break the potential deadlock.

    1. Analyze the Worst-Case Scenario

    A deadlock occurs if every process holds the maximum number of resources it can hold without completing, and no process can proceed. In this scenario:

    • There are 5 processes.

    • Each process requires a maximum of 2 instances.

    • A process can request the second instance only after acquiring the first. This means a process can hold 1 instance and wait for the second.

    In the worst-case scenario (potential deadlock), each of the 5 processes holds 1 instance of the resource and is waiting for the second instance. No process can proceed because no resources are available to satisfy the second request.

    2. Calculate Resources in Deadlock State

    Number of processes = 5 Resources held per process in worst case = 1 Total resources held = 5 × 1 = 5

    3. Determine Minimum k for Deadlock-Free System

    To prevent deadlock, we need at least one extra resource beyond the worst-case scenario. This extra resource allows one process to acquire its second instance, complete its execution, and release both instances, thereby allowing other processes to proceed.

    Minimum k = (Resources in worst case) + 1 Minimum k = 5 + 1 = 6

    Final Answer

    The minimum value of k for the system to be deadlock-free is 6.

    Practice this question →

  70. Q70.GATE 2026

    Consider a knock-out women’s badminton singles tournament where there are no ties. The loser in each game is eliminated from the tournament. Every player plays until she is defeated or remains the last undefeated player. The last undefeated player is declared the winner of the tournament. If there are 64 players in the beginning of the tournament, how many games should be played in total to declare the winner of the tournament?

    1. A.

      127

    2. B.

      64

    3. C.

      63

    4. D.

      32

    Correct answer: C

    Solution

    In a knockout tournament with no ties, every game eliminates exactly one player. To declare one winner from 64 players, 63 players must be eliminated. Therefore, the total number of games required is 64 - 1 = 63.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  71. Q71.GATE 2026

    A student needs to enroll for a minimum of 60 credits. A student cannot enroll for more than 70 credits. The credits are divided amongst project and three distinct sets of courses namely, core courses, specialization courses, and elective courses. It is compulsory for a student to enroll for exactly 15 credits of core courses and exactly 20 credits of project. In addition, a student has to enroll for a minimum of 10 credits of specialization courses. The maximum credits of elective courses that a student can enroll for is ______

    1. A.

      10

    2. B.

      15

    3. C.

      20

    4. D.

      25

    Correct answer: D

    Solution

    To maximize elective credits, the student should enroll for the maximum allowed total credits, which is 70. The compulsory credits are 15 for core courses and 20 for the project. The minimum specialization credits are 10. Therefore, maximum elective credits = 70 - 15 - 20 - 10 = 25.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  72. Q72.GATE 2026

    ‘When the teacher is in the room, all students stand silently.’ If the above statement is true, which one of the following statements is not necessarily true?

    1. A.

      If any student is not standing silently, then the teacher is not in the room.

    2. B.

      When the teacher is in the room, all students are silent.

    3. C.

      If all students are standing, then the teacher is in the room.

    4. D.

      When the teacher is in the room, all students are standing.

    Correct answer: C

    Solution

    Let T mean “the teacher is in the room” and S mean “all students stand silently.” The given statement says T → S. From this, we can conclude S whenever T is true, and we can also conclude the contrapositive ¬S → ¬T. However, the converse S → T is not necessarily true. Students may all be standing even when the teacher is not in the room. Therefore, the statement “If all students are standing, then the teacher is in the room” is not necessarily true.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  73. Q73.GATE 2026

    Combinatorics deals with problems involving counting. For example, “How many distinct arrangements of N distinct objects in M spaces on a circle are possible?” is a typical problem in combinatorics. This kind of counting is sometimes used in the modeling of several physical phenomena. Often, in such models, the different combinatorial possibilities are assigned probability values. Assigning probabilities enables the computation of the average values of physical quantities.

    Consider the following statements:

    P: Combinatorics is always invoked in the modeling of physical phenomena.

    Q: Modeling some physical phenomena involves assigning probabilities to combinatorial possibilities in order to compute average values of physical quantities.

    Based on the passage above, what can be inferred about statements P and Q?

    1. A.

      P is False and Q is False

    2. B.

      P is False and Q is True

    3. C.

      P is True and Q is False

    4. D.

      P is True and Q is True

    Correct answer: B

    Solution

    Statement P claims combinatorics is always invoked, but the passage states it is often used. Thus, P is false. Statement Q aligns with the text regarding assigning probabilities to compute average values. Therefore, Q is true.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  74. Q74.GATE 2026

    In Panel I of the figure below, the front view and top view of a structure are shown. Which one of the 3D structures shown in Panel II possesses the views shown in Panel I?

    image.png

    1. A.

      (i)

    2. B.

      (ii)

    3. C.

      (iii)

    4. D.

      (iv)

    Correct answer: D

    Solution

    Compare each candidate structure with the two projections in Panel I. The correct structure must match the L-shaped front view and also have the same footprint when viewed from the top. Options (i), (ii), and (iii) fail to match one of these two projections. Option (iv) matches both the front view and the top view, so it is the required 3D structure.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  75. Q75.GATE 2026

    For positive real numbers S and K, the function HK(S) is defined as:

    HK(S) = max(S - K, 0). The max function is defined as:

    max function definition

    The graph below shows the plot of a function N(S) versus S.

    N(S) can be expressed as _____.

    graph of N(S) versus S

    1. A.

      𝐻10(𝑆)−𝐻20(𝑆)

    2. B.

      𝐻10(𝑆)−2𝐻20(𝑆)

    3. C.

      -𝐻10(𝑆)+𝐻20(𝑆)

    4. D.

      𝐻15(𝑆)−𝐻20(𝑆)

    Correct answer: A

    Solution

    H_K(S) = max(S - K, 0) is zero for S <= K and equals S - K for S > K.

    For H_10(S) - H_20(S):
    - If S <= 10, both terms are zero, so the value is 0.
    - If 10 < S <= 20, H_10(S) = S - 10 and H_20(S) = 0, so the value is S - 10.
    - If S > 20, H_10(S) = S - 10 and H_20(S) = S - 20, so the value is 10.

    This gives exactly the plotted capped ramp: 0 until S = 10, increasing linearly to 10 at S = 20, and then remaining constant at 10. Therefore N(S) = H_10(S) - H_20(S).

    Practice this question →

  76. Q76.GATE 2026

    In the 2020 Summer Olympics javelin throw final, Neeraj Chopra produced a spectacular performance to win the gold medal. Jakub Vadlejch won the silver medal, and Vítězslav Veselý won the bronze medal. There were six rounds of throws, with each athlete having one throw per round. Each athlete’s best valid throw was considered for the medals. The following observations were given:

    1. Neeraj Chopra dominated the first and second rounds, producing his gold-medal performance with his second throw, while the other two athletes had no medal-winning throw in these rounds.

    2. The last-round throws of both Jakub Vadlejch and Vítězslav Veselý were fouls and were not considered for scoring.

    3. After four rounds, Vítězslav Veselý was in second position; neither of his succeeding throws equalled or improved on the best throw he had already recorded.

    4. In the fourth round, Jakub Vadlejch made the sole best valid throw of that round, strictly longer than every other valid throw in that round.

    In which round did Vítězslav Veselý first record the throw that remained his best?

    1. A.

      Third

    2. B.

      Fourth

    3. C.

      Fifth

    4. D.

      Sixth

    Correct answer: A

    Solution

    Concept

    In a ranking puzzle, if one competitor is already ahead and another competitor also strictly exceeds a third competitor, that third competitor cannot hold second place. Candidate cases can therefore be eliminated by combining score validity, timing constraints, and strict rank order.

    Application

    1. Observation (i) rules out rounds 1 and 2: Neeraj’s medal-winning throws occurred there, while Vítězslav Veselý had no medal-winning throw in either round.

    2. Observation (iii) says neither of Veselý’s later throws equalled or improved on the best he had after four rounds. Therefore, rounds 5 and 6 cannot be when he first recorded his best; observation (ii) also identifies his round-6 attempt as a foul.

    3. Only rounds 3 and 4 remain. Suppose Veselý first recorded his best throw in round 4.

    4. Observation (iv) says Jakub Vadlejch’s round-4 throw was strictly longer than every other valid throw in that round, including Veselý’s assumed personal best. Neeraj’s gold-medal throw was already ahead, so Jakub would also be ahead of Veselý. Veselý would then be third after four rounds, contradicting observation (iii), which places him second.

    Cross-check

    The official World Athletics series independently confirms the deduction: Veselý’s six attempts were 79.73 m, 80.30 m, 85.44 m, foul, 84.98 m, and foul. His unique best was therefore 85.44 m in round 3. IIT Guwahati’s official GATE 2026 answer key for this master-paper question likewise identifies ‘Third’ as the correct answer.

    Result

    Vítězslav Veselý first recorded his best throw in the third round.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  77. Q77.GATE 2026

    An unbiased six-faced dice whose faces are marked with numbers 1, 2, 3, 4, 5, and 6 is rolled twice in succession and the number on the top face is recorded each time. The probability that the number appearing in the second roll is an integer multiple of the number appearing in the first roll is __________

    1. A.

      1/6

    2. B.

      5/18

    3. C.

      7/18

    4. D.

      5/6

    Correct answer: C

    Solution

    For each first roll a, count the possible second rolls b such that b is an integer multiple of a.

    If a = 1, b can be 1, 2, 3, 4, 5, 6: 6 outcomes.
    If a = 2, b can be 2, 4, 6: 3 outcomes.
    If a = 3, b can be 3, 6: 2 outcomes.
    If a = 4, 5, or 6, only b = a works: 1 outcome each.

    Total favorable ordered pairs = 6 + 3 + 2 + 1 + 1 + 1 = 14.
    Total possible ordered pairs = 6 × 6 = 36.

    Therefore, the required probability is 14/36 = 7/18.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  78. Q78.GATE 2026

    An urn contains one red ball and one blue ball. At each step, a ball is picked uniformly at random from the urn, and this ball together with another ball of the same color is put back in the urn. The probability that there are equal number of red and blue balls after two steps is

    1. A.

      1/4

    2. B.

      1/3

    3. C.

      1/2

    4. D.

      2/3

    Correct answer: B

    Solution

    Initially, the urn contains 1 red ball and 1 blue ball (total 2).

    After Step 1, picking either color (probability 1/2 each) changes the composition. If Red is picked first, the urn has 2R and 1B (total 3). If Blue is picked first, the urn has 1R and 2B (total 3).

    To have equal numbers (2R, 2B) after Step 2, we need the opposite color in the second step. From (2R, 1B), picking Blue has probability 1/3. From (1R, 2B), picking Red has probability 1/3.

    Total probability = (1/2 * 1/3) + (1/2 * 1/3) = 1/6 + 1/6 = 1/3.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  79. Q79.GATE 2026

    Consider 4×4 matrices with their elements from {𝟎,𝟏}. The number of such matrices with even number of 𝟏s in every row and every column is

    1. A.

      512

    2. B.

      1025

    3. C.

      1023

    4. D.

      255

    Correct answer: A

    Solution

    Choose the entries in the first 3 rows and first 3 columns arbitrarily. This gives 3 × 3 = 9 independent binary choices, so there are 2^9 possibilities. Once these 9 entries are fixed, the entries in the fourth column are determined by the requirement that each of the first three rows has even parity. Similarly, the entries in the fourth row are determined by the requirement that each of the first three columns has even parity. The bottom-right entry is then automatically consistent because the total parity of all row sums and all column sums must match. Therefore, the number of such matrices is 2^9 = 512.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  80. Q80.GATE 2026

    For 𝑛 > 1, the maximum multiplicity of any eigenvalue of an 𝑛×𝑛 matrix with elements from ℝ is

    1. A.

      n

    2. B.

      n-1

    3. C.

      1

    4. D.

      n+1

    Correct answer: A

    Solution

    The multiplicity of an eigenvalue refers to its algebraic multiplicity, i.e., the number of times it appears as a root of the characteristic polynomial.

    For an n×n matrix:

    • The characteristic polynomial has degree n.

    • Therefore, the sum of the algebraic multiplicities of all eigenvalues is exactly n.

    • Hence, the maximum possible multiplicity of a single eigenvalue is n.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  81. Q81.GATE 2026

    Match each addressing mode in List I with a data element or an element of a data structure (in a high-level language) in List II:

    image.png

    1. A.

      P–4, Q–3, R–1, S–2

    2. B.

      P–4, Q–2, R–1, S–3

    3. C.

      P–1, Q–4, R–3, S–2

    4. D.

      P–2, Q–3, R–1, S–4

    Correct answer: B

    Solution

    To solve this matching question, we need to understand the typical use cases for each addressing mode in high-level programming contexts.

    1. Immediate Mode (P): In this mode, the operand is a constant value specified directly within the instruction itself. Therefore, it corresponds to a Constant (4).

    2. Indirect Mode (Q): Here, the address field contains the address of the operand, which is stored in a memory location. This is commonly used to access Pointers (2).

    3. Base with Index (R): This mode uses a base register and an index register. The base register holds the starting address, and the index register holds the offset. This is typically used to access an Element of an array (1).

    4. Base with Offset/Displacement (S): This mode uses a base register and a displacement value. The base register points to the start of a data structure, and the offset points to a specific field. This is used to access an Element of a record (3).

    Matching these: P-4, Q-2, R-1, S-3.

    Practice this question →

  82. Q82.GATE 2026

    Consider a processor P whose instruction set architecture is the load-store architecture. The instruction format is such that the first operand of any instruction is the destination operand.

    Which one of the following sequences of instructions corresponds to the high-level language statement Z = X + Y ?

    Note: X, Y, and Z are memory operands. R0, R1, and R2 are registers.

    1. A.

      ADD Z, X, Y

    2. B.

      LOAD R0, X

      ADD Z, R0, Y

    3. C.

      ADD R0, X, Y

      STORE Z, R0

    4. D.

      LOAD R0, X

      LOAD R1, Y

      ADD R2, R0, R1

      STORE Z, R2

    Correct answer: D

    Solution

    In a load-store architecture, arithmetic operations can only be performed on data stored in registers. Memory operands cannot be directly accessed by arithmetic instructions.

    To implement Z = X + Y, where X, Y, and Z are memory operands, the data must first be moved from memory to registers.

    The correct sequence involves loading X into a register, loading Y into another register, adding the two registers, and storing the result into Z.

    This ensures compliance with the instruction format where the first operand is the destination and all arithmetic sources are registers.

    Practice this question →

  83. Q83.GATE 2026

    Which one of the following dependencies among the register operands of different instructions can cause a data hazard in a pipelined processor?

    1. A.

      Read-after-read

    2. B.

      Read-after-write

    3. C.

      Write-after-read

    4. D.

      Write-after-write

    Correct answer: B

    Solution

    In a pipelined processor, a data hazard occurs when one instruction depends on the result of another instruction that has not yet completed.

    The most common dependency causing this problem is:Read After Write (RAW)

    Here, a later instruction needs to read a value that an earlier instruction is still in the process of writing.

    Therefore, the correct answer is:

    B) Read-after-write

    Practice this question →

  84. Q84.GATE 2026

    Consider the following recurrence relations:

    For all 𝑛>1,

    𝑇1(𝑛) = 4𝑇1(𝑛 / 2) + 𝑇2(𝑛)

    𝑇2(𝑛) = 5𝑇2(𝑛 / 4) + Θ(log2𝑛)

    Assume that for all 𝑛≤ 1,𝑇1(𝑛) =1 and 𝑇2(𝑛) = 1.

    Which one of the following options is correct?

    1. A.

      𝑇1(𝑛)=Θ(𝑛2)

    2. B.

      𝑇1(𝑛)=Θ(𝑛2log2𝑛)

    3. C.

      𝑇1(𝑛)=Θ(𝑛log45)

    4. D.

      𝑇1(𝑛)=Θ(𝑛log45 log2𝑛)

    Correct answer: A

    Solution

    Solution

    Step 1: Analyze T2(n). Using Master Theorem with a=5, b=4, we get Theta(n^log4 5).

    Step 2: Substitute into T1(n). The recurrence becomes T1(n) = 4T1(n/2) + Theta(n^log4 5).

    Step 3: Apply Master Theorem again. Here a=4, b=2, so log_b a = 2.

    Step 4: Compare n^log4 5 with n^2. Since 2 > log4 5, the n^2 term dominates.

    Practice this question →

  85. Q85.GATE 2026

    With respect to a TCP connection between a client and a server, which one of the following statements is true?

    1. A.

      The client and server use a two-way handshake mechanism before the start of data transmission

    2. B.

      The server cannot initiate closing of the connection before the client initiates closing of the connection

    3. C.

      The TCP connection is half-duplex

    4. D.

      The client and server can initiate closing of the connection at the same time

    Correct answer: D

    Solution

    The client and server can initiate closing of the connection at the same time

    Practice this question →

  86. Q86.GATE 2026

    Which of the following statements is/are true with respect to the interaction of a web browser with a web server using HTTP 1.1?

    1. A.

      HTTP 1.1 facilitates downloading multiple objects of the same webpage over the same TCP connection, if the objects are stored in the same server

    2. B.

      HTTP 1.1 facilitates downloading multiple objects of the same webpage over the same TCP connection, even if they are stored in different servers

    3. C.

      HTTP 1.1 facilitates sending a request for downloading one object without waiting for a previously requested object to be downloaded completely

    4. D.

      HTTP 1.1 facilitates downloading multiple webpages on the same server to be downloaded over a single TCP connection

    Correct answer: A, C, D

    Solution

    HTTP/1.1 supports persistent connections, allowing multiple objects or webpages from the same server over a single TCP connection. It also supports pipelining, which permits sending multiple requests without waiting for previous responses. However, a single TCP connection cannot span multiple distinct servers.

    Practice this question →

  87. Q87.GATE 2026

    Let 𝑛 > 1. Consider an 𝑛×𝑛 matrix 𝑀 with its elements from ℝ. Let the vector (0,1,0,0,…,0)∈ℝ𝑛 be in the null space of 𝑀.

    Which of the following options is/are always correct?

    1. A.

      Determinant of 𝑀 is 1

    2. B.

      Determinant of 𝑀 is 0

    3. C.

      Rank of 𝑀 is 1

    4. D.

      There are at least two non-zero vectors in the null space of 𝑀

    Correct answer: B, D

    Solution

    For a real n×n matrix M, the null space (kernel) is the set of vectors x with Mx = 0. Two governing facts follow directly from linear algebra: (1) M is singular — equivalently det(M) = 0 — exactly when its null space contains a nonzero vector, since a nonzero solution of Mx = 0 means the columns of M are linearly dependent; and (2) the null space is itself a linear subspace, so it is closed under scalar multiplication — once it holds one nonzero vector, it holds every nonzero scalar multiple of that vector.

    1. The vector (0, 1, 0, …, 0) is the second standard basis vector, e2. It is nonzero and, by hypothesis, lies in the null space of M, so M e2 = 0.

    2. Multiplying M by e2 extracts the second column of M, so M e2 = 0 means the second column of M is the zero column.

    3. A matrix with a zero column has linearly dependent columns, so by fact (1) it is singular — hence det(M) = 0 for every such M.

    4. By fact (2), since e2 is a nonzero vector in the null space, every nonzero scalar multiple c·e2 (c ≠ 0) is also in the null space — giving infinitely many nonzero null-space vectors, so certainly at least two.

    Cross-check against the other claims:

    • A determinant of 1 would require M to be invertible, but an invertible matrix cannot have a nonzero vector in its null space — so this value is impossible here, consistent with fact (1) instead forcing det(M) = 0.

    • The rank is not pinned to any single number: only the second column is forced to be zero, while the remaining n − 1 columns can still be chosen linearly independent, so the rank can be as large as n − 1.

    So the properties that hold for every matrix M satisfying the given condition are: det(M) = 0, and the null space contains at least two nonzero vectors.

    Practice this question →

  88. Q88.GATE 2026

    Consider the 8-bit signed integers 𝑋,𝑌 and 𝑍 represented using the sign-magnitude form. The binary representations of 𝑋 and 𝑌 are as follows:

    X: 10110100 𝑌: 01001100

    Which of the following operations to compute 𝑍 result(s) in an arithmetic overflow?

    1. A.

      Z=𝑋+𝑌

    2. B.

      Z=𝑋-𝑌

    3. C.

      Z=-𝑋+𝑌

    4. D.

      Z=-𝑋-𝑌

    Correct answer: B, C

    Solution

    Solution

    Step 1: Convert binary to decimal. X = 10110100 (Sign-Magnitude) = -52. Y = 01001100 = +76.

    Step 2: Determine range. 8-bit signed magnitude range is -127 to +127.

    Step 3: Evaluate operations. A: -52 + 76 = 24 (Valid). B: -52 - 76 = -128 (Overflow). C: 52 + 76 = 128 (Overflow). D: 52 - 76 = -24 (Valid).

    Step 4: Conclusion. Operations B and C result in overflow.

    Practice this question →

  89. Q89.GATE 2026

    Let 𝑛 be an odd number greater than 100. Consider a binary minheap with n elements stored in an array 𝑃 whose index starts from 1. Which of the following indices of 𝑃 do/does NOT correspond to any leaf node of the minheap?

    1. A.

      n+1/2

    2. B.

      n-1/2

    3. C.

      n-3/2

    4. D.

      n

    Correct answer: B, C

    Solution

    In a binary heap with n elements using 1-based indexing, the parent of node i is floor(i/2). A node i has children if 2*i <= n. Therefore, nodes with indices from 1 to floor(n/2) are internal nodes (non-leaves), and nodes with indices from floor(n/2)+1 to n are leaf nodes. Since n is odd, floor(n/2) equals (n-1)/2. Thus, any index less than or equal to (n-1)/2 does not correspond to a leaf node.

    Practice this question →

  90. Q90.GATE 2026

    Consider a hash table 𝑃[0,1,…,10] that is initially empty. The hash table is maintained using open addressing with linear probing. The hash function used is ℎ(𝑥)=(𝑥+7) mod 11.

    Consider the following sequence of insertions performed on 𝑃:

    1,13,22,15,11,24

    Which of the following positions in the hash table is/are empty after these insertions are performed?

    1. A.

      0

    2. B.

      10

    3. C.

      2

    4. D.

      1

    Correct answer: C

    Solution

    The hash table has size 11 (indices 0-10). The hash function is h(x) = (x + 7) mod 11. We use linear probing for collisions.

    1. Insert 1: h(1) = (1+7)%11 = 8. Slot 8 is empty. Place 1 at index 8.

    2. Insert 13: h(13) = (13+7)%11 = 9. Slot 9 is empty. Place 13 at index 9.

    3. Insert 22: h(22) = (22+7)%11 = 7. Slot 7 is empty. Place 22 at index 7.

    4. Insert 15: h(15) = (15+7)%11 = 0. Slot 0 is empty. Place 15 at index 0.

    5. Insert 11: h(11) = (11+7)%11 = 7. Slot 7 occupied. Probe 8 (occupied), 9 (occupied), 10 (empty). Place 11 at index 10.

    6. Insert 24: h(24) = (24+7)%11 = 9. Slot 9 occupied. Probe 10 (occupied), 0 (occupied), 1 (empty). Place 24 at index 1.

    Final occupied indices: 0, 1, 7, 8, 9, 10. Empty indices: 2, 3, 4, 5, 6.

    Practice this question →

  91. Q91.GATE 2026

    Let M be a nondeterministic finite automaton (NFA) with 6 states over a finite alphabet.

    Which of the following options CANNOT be the number of states in the minimal deterministic finite automaton (DFA) that is equivalent to 𝑀 ?

    1. A.

      32

    2. B.

      65

    3. C.

      1

    4. D.

      128

    Correct answer: B, D

    Solution

    Step 1: Understand the relationship between NFA and DFA states. An NFA with n states can be converted to a DFA with at most 2^n states using the subset construction method.

    Step 2: Calculate the maximum number of states. Given n = 6, the maximum number of states in the equivalent DFA is 2^6 = 64.

    Step 3: Determine the valid range. The number of states in the minimal DFA equivalent to an NFA with n states must be between 1 and 2^n inclusive.

    Step 4: Evaluate the options. Options 32 and 1 are within the range [1, 64]. Options 65 and 128 exceed the maximum limit of 64.

    Conclusion: The options that CANNOT be the number of states are 65 and 128.

    Practice this question →

  92. Q92.GATE 2026

    Consider the following C statements:

    char str1 = "Hello; / Statement S1 /

    char str2 = "Hello;"; /* Statement S2 /

    int str3 = "Hello"; /* Statement S3 */

    Which of the following options is/are correct?

    1. A.

      S1 and S2 have syntactic errors

    2. B.

      S2 has a lexical error and S3 has a syntactic error

    3. C.

      S1 has a lexical error and S3 has a semantic error

    4. D.

      S1 has a syntactic error and S3 has a semantic error

    Correct answer: C

    Solution

    Statement S1 contains an unclosed string literal, which causes a lexical error because the tokenizer cannot identify the end of the token. Statement S3 attempts to assign a string literal to an integer variable, which is a type mismatch classified as a semantic error. Option 2 correctly identifies S1's lexical error and S3's semantic error, matching standard compiler behavior for these specific code snippets.

    Practice this question →

  93. Q93.GATE 2026

    Which of the following statements is/are true?

    1. A.

      LL(1) parser uses backtracking

    2. B.

      For a grammar to be LL(1), it must be left-recursive

    3. C.

      For a grammar to be LL(1), it must be left-factored

    4. D.

      The LL(1) parsers are more powerful than the SLR parsers

    Correct answer: C

    Solution

    LL(1) parsers are predictive parsers that scan input from left to right and construct a leftmost derivation. They use one token of lookahead to decide which production rule to apply.

    A grammar must be left-factored to be LL(1). This transformation removes common prefixes from production rules, ensuring the parser can choose the correct rule based on the next input token.

    LL(1) grammars cannot be left-recursive. Left recursion causes infinite loops in top-down parsing, so it must be eliminated before parsing table construction.

    SLR parsers are more powerful than LL(1) parsers. The class of grammars accepted by SLR parsers is a superset of those accepted by LL(1) parsers.

    Practice this question →

  94. Q94.GATE 2026

    With respect to deadlocks in an operating system, which of the following statements is/are FALSE?

    1. A.

      Banker’s algorithm is used to prevent deadlocks

    2. B.

      Deadlock formation can be prevented by ensuring that the hold and wait condition is not allowed

    3. C.

      An assignment edge in a resource allocation graph is marked from a process to a resource

    4. D.

      A safe state guarantees that all processes can finish without formation of a deadlock

    Correct answer: A, C

    Solution

    Statement A is false because the Banker’s algorithm prevents deadlock through avoidance, not prevention. Statement C is false since assignment edges in a resource allocation graph point from resources to processes, indicating allocation. Statements B and D correctly describe deadlock prevention conditions and safe states.

    Practice this question →

  95. Q95.GATE 2026

    Let 𝑃,𝑄,𝑅 and 𝑆 be the attributes of a relation in a relational schema. Let 𝑋 ⟶𝑌 indicate functional dependency in the context of a relational database, where X,Y ⊆{𝑃,𝑄,𝑅,𝑆}.

    Which of the following options is/are always true?

    1. A.

      If ( {𝑃,𝑄} ⟶{𝑅} and {𝑃} ⟶{𝑅} ), then {𝑄} ⟶{𝑅}

    2. B.

      If {𝑃,𝑄} ⟶{𝑅}, then ( {𝑃} ⟶{𝑅} or {𝑄} ⟶{𝑅} )

    3. C.

      If ( {𝑃} ⟶{𝑅} and {𝑄} ⟶{𝑆} ), then {𝑃,𝑄} ⟶{𝑅,𝑆}

    4. D.

      If {𝑃} ⟶{𝑅}, then {𝑃,𝑄} ⟶{𝑅}

    Correct answer: C, D

    Solution

    Functional dependencies (FDs) define relationships where one set of attributes determines another in a relational schema.

    The Union Rule states that if P ⟶ R and Q ⟶ S, then {P, Q} ⟶ {R, S}. This validates Option C as always true.

    The Augmentation Rule states that if P ⟶ R, then {P, Q} ⟶ {R, S}. Adding attributes to the determinant preserves the dependency, validating Option D.

    Other options are incorrect because composite dependencies do not imply individual determinants without specific constraints.

    Practice this question →

  96. Q96.GATE 2026

    In the context of relational database normalization, which of the following statements is/are true?

    1. A.

      It is always possible to obtain a dependency-preserving 3NF decomposition of a relation

    2. B.

      It is always possible to obtain a dependency-preserving 1NF decomposition of a relation

    3. C.

      It is not always possible to obtain a dependency-preserving BCNF decomposition of a relation

    4. D.

      It is not always possible to obtain a dependency-preserving 2NF decomposition of a relation

    Correct answer: A, B, C

    Solution

    In relational database normalization, 3NF decomposition always preserves dependencies using synthesis algorithms. All relations can be decomposed into 1NF while preserving dependencies. However, BCNF decomposition may lose dependencies in some cases. Option D is false because 2NF decompositions can preserve dependencies.

    Practice this question →

  97. Q97.GATE 2026

    The height of a binary tree is the number of edges in the longest path from the root to a leaf in the tree. The maximum possible height of a full binary tree with 23 nodes is _________. (answer in integer)

    Correct answer: 11

    Solution

    In a full binary tree, every node has either:

    • 0 children, or

    • 2 children.

    For a full binary tree:Number of nodes=2i+1
    where iii = number of internal nodes.

    Given:

    n=23n = 23n=23

    To get the maximum height, we make the tree as skewed as possible while still remaining full.

    In a full binary tree with maximum height:

    • each internal node contributes one extra level,

    • and one subtree continues the chain while the other is a leaf.

    Number of internal nodes:

    image.png

    Practice this question →

  98. Q98.GATE 2026

    Consider the real valued variables X, Y and Z represented using the IEEE 754 single precision floating-point format. The binary representations of X and Y in hexadecimal notation are as follows:

    X: 35C00000 Y: 34A00000

    Let 𝑍 = 𝑋+𝑌.

    Which one of the following is the binary representation of 𝑍, in hexadecimal notation?

    1. A.

      35C80000

    2. B.

      35CC0000

    3. C.

      35E80000

    4. D.

      35EC0000

    Correct answer: C

    Solution

    Step 1: Convert Hexadecimal to Binary

    Convert X and Y from hexadecimal to 32-bit binary representation.

    X: 35C00000 -> 0011 0101 1100 0000 0000 0000 0000 0000

    Y: 34A00000 -> 0011 0100 1010 0000 0000 0000 0000 0000

    Step 2: Parse IEEE 754 Fields

    X: Sign=0, Exponent=01101011 (107), Mantissa=1.1000...

    Y: Sign=0, Exponent=01101001 (105), Mantissa=1.0100...

    Step 3: Align Exponents

    Difference in exponents is 2. Shift Y's mantissa right by 2 bits.

    Y Mantissa becomes 0.010100... (aligned to exponent 107)

    Step 4: Add Mantissas

    Add X and aligned Y mantissas: 1.1000... + 0.010100... = 1.110100...

    Step 5: Convert Result to Hex

    Result Binary: 0011 0101 1110 1000 0000 0000 0000 0000

    Hexadecimal: 35E80000

    Practice this question →

  99. Q99.GATE 2026

    The size of the physical address space of a processor is 232 bytes. The capacity of a cache memory unit is 223 bytes. The cache block size is 128 bytes. The cache memory unit can be built as a direct mapped cache or as a 𝐾-way set-associative cache, where 𝐾= 2𝐿 and 𝐿∈{1,2,3}. Let the length of the TAG field be 𝑀 bits for the direct mapped cache, and 𝑁 bits for the set-associative cache. Which one of the following options is true?

    1. A.

      N=𝑀+𝐿

    2. B.

      N=𝑀-𝐿

    3. C.

      N=𝑀+K

    4. D.

      N=𝑀-K

    Correct answer: A

    Solution

    Given:

    Physical address space = 2^32 bytes
    Cache size = 2^23 bytes
    Block size = 128 bytes = 2^7 bytes

    --------------------------------------------------
    Step 1: Block Offset Bits
    --------------------------------------------------

    Block offset bits = log2(128)
    = 7 bits

    --------------------------------------------------
    Step 2: Direct Mapped Cache
    --------------------------------------------------

    Number of cache lines:

    = 2^23 / 2^7
    = 2^16

    Index bits = 16

    TAG bits for direct mapped cache:

    M = 32 - 16 - 7
    M = 9 bits

    --------------------------------------------------
    Step 3: K-Way Set Associative Cache
    --------------------------------------------------

    Given:

    K = 2^L

    Number of sets:

    = 2^16 / 2^L
    = 2^(16-L)

    Set index bits:

    = 16 - L

    TAG bits:

    N = 32 - (16-L) - 7
    N = 32 - 16 + L - 7
    N = 9 + L

    But,

    M = 9

    Therefore,

    N = M + L

    --------------------------------------------------
    Final Answer
    --------------------------------------------------

    Option A is correct.

    N = M + L
    """

    Practice this question →

  100. Q100.GATE 2026

    Consider the following code snippet in C language that computes the number of nodes in a non-empty singly linked list pointed to by the pointer variable head.

    struct node{

    int elt;

    struct node *next;

    };

    int getListSize (struct node *head)

    {

    if( E1 ) return 1;

    return E2;

    }

    Which one of the following options gives the correct replacements for the expressions E1 and E2?

    1. A.

      E1: head == NULL

      E2: 1 + getListSize(head)

    2. B.

      E1: head->next == NULL

      E2: 1 + getListSize(head->next)

    3. C.

      E1: head == NULL

      E2: 1 + getListSize(head->next)

    4. D.

      E1: head->next == NULL

      E2: 1 + getListSize(head)

    Correct answer: B

    Solution

    The function counts nodes recursively. For the base case (E1), check if the current node is the last one by verifying head->next == NULL.

    For the recursive step (E2), add 1 for the current node and recurse on the next pointer: 1 + getListSize(head->next).

    Practice this question →

  101. Q101.GATE 2026

    Let 𝑃 be the set of all integers from 1 to 15. Consider any order of insertion of the elements of 𝑃 into a binary search tree that creates a complete binary tree.

    Which one of the following elements can NEVER be the third element that is inserted?

    1. A.

      4

    2. B.

      2

    3. C.

      10

    4. D.

      5

    Correct answer: D

    Solution

    To form a complete BST using numbers 1 to 15,
    the final BST must be perfectly balanced.

    Hence:

    Root = 8

    Its immediate children must be:

    Left child = 4
    Right child = 12

    Now analyze insertion order.

    1st inserted element:
    Must be 8 (root)

    2nd inserted element:
    Must be either 4 or 12

    3rd inserted element:
    Must become the other child of root.

    Therefore, the third inserted element can only be:

    4 or 12

    --------------------------------------------------
    Checking Options
    --------------------------------------------------

    Option 1: 4
    Possible as third insertion.

    Option 2: 2
    Possible if:
    8, 4, 2
    This can still later form a complete BST.

    Option 3: 10
    Possible if:
    8, 12, 10

    Option 4: 5
    Impossible as third insertion.

    Reason:
    If 5 is inserted before 4 exists,
    then 5 becomes direct left child of 8,
    which violates the required complete BST structure.

    Hence, 5 can NEVER be the third inserted element.

    --------------------------------------------------
    Final Answer
    --------------------------------------------------

    5
    """

    Practice this question →

  102. Q102.GATE 2026

    Let 𝐺(𝑉,𝐸) be an undirected, edge-weighted graph with integer weights. The weight of a path is the sum of the weights of the edges in that path. The length of a path is the number of edges in that path.

    Let S∈𝑉 be a vertex in 𝐺. For every 𝑢∈𝑉 and for every 𝑘 ≥0, let 𝑑𝑘(𝑢) denote the weight of a shortest path (in terms of weight) from 𝑠 to 𝑢 of length at most 𝑘. If there is no path from 𝑠 to 𝑢 of length at most 𝑘, then 𝑑𝑘(𝑢)=∞.

    Consider the statements:

    S1: For every 𝑘 ≥0 and 𝑢 ∈𝑉, 𝑑𝑘+1(𝑢)≤𝑑𝑘(𝑢).

    S2: For every (𝑢,𝑣)∈𝐸, if (𝑢,𝑣) is part of a shortest path (in terms of weight) from 𝑠 to 𝑣, then for every 𝑘≥ 0,𝑑𝑘(𝑢)≤𝑑𝑘(𝑣).

    Which one of the following options is correct?

    1. A.

      Only S1 is true

    2. B.

      Only S2 is true

    3. C.

      Both S1 and S2 are true

    4. D.

      Neither S1 nor S2 is true

    Correct answer: A

    Solution


    Given:

    d_k(u) denotes the shortest path weight from s to u
    using at most k edges.

    --------------------------------------------------
    Statement S1
    --------------------------------------------------

    d_(k+1)(u) <= d_k(u)

    Reason:

    All paths allowed for d_k(u)
    are also allowed for d_(k+1)(u).

    Allowing one extra edge can only improve
    or maintain the shortest path value.

    Therefore:

    S1 is TRUE.

    --------------------------------------------------
    Statement S2
    --------------------------------------------------

    Claim:

    d_k(u) <= d_k(v)

    This is FALSE.

    Counterexample:

    s -> u = 5
    u -> v = -10

    Then:

    d(u) = 5
    d(v) = -5

    Thus:

    d(u) > d(v)

    Hence the statement does not always hold.

    Therefore:

    S2 is FALSE.

    --------------------------------------------------
    Final Answer
    --------------------------------------------------

    Only S1 is true.
    """

    Practice this question →

  103. Q103.GATE 2026

    A TCP sender successfully establishes a connection with a TCP receiver and starts the transmission of segments. The TCP congestion control mechanism’s slow-start threshold is set to 10000 segments. Assume that the round-trip time is fixed at 1 millisecond. Assume that the sender always has data to send, the segments are numbered from 1, and no segment is lost. Let 𝑡 denote the time (in milliseconds) at which the transmission of segment number 2000 starts.

    Which one of the following options is correct?

    1. A.

      9 ≤ 𝑡 < 10

    2. B.

      10 ≤ 𝑡 < 11

    3. C.

      11 ≤ 𝑡 < 12

    4. D.

      12 ≤ 𝑡 < 13

    Correct answer: B

    Solution

    In TCP slow-start, the congestion window (cwnd) doubles every RTT. Starting with cwnd = 1 segment at t=0, the number of segments sent in round k is 2^k. The cumulative segments sent by time t=k is sum(2^i for i=0 to k) = 2^(k+1) - 1. At t=9, cumulative segments = 2^10 - 1 = 1023. At t=10, cumulative segments = 2^11 - 1 = 2047. Since segment 2000 falls between 1023 and 2047, it is transmitted during the round starting at t=10. Thus, transmission starts at t = 10 ms.

    Practice this question →

  104. Q104.GATE 2026

    Consider the implementation of sliding window protocol over a lossless link, with a window size of 𝑊 frames, where each frame is of size 1000 bits (including header). The bandwidth of the link is 100 kbps (1k = 103) and the one-way propagation delay is 100 milliseconds. Assume that processing times at the sender and receiver are zero and the transmission time of acknowledgements is also zero. Which one of the following options gives the minimum size of 𝑊 (in number of frames) required to achieve 100% link utilization?

    1. A.

      10

    2. B.

      21

    3. C.

      20

    4. D.

      11

    Correct answer: B

    Solution

    Solution

    Given:

    Frame size = 1000 bits
    Bandwidth = 100 kbps
    Propagation delay = 100 ms

    --------------------------------------------------
    Step 1: Transmission Time
    --------------------------------------------------

    Transmission time:

    Tt = Frame Size / Bandwidth

    = 1000 / (100 x 10^3)

    = 0.01 s

    = 10 ms

    --------------------------------------------------
    Step 2: Propagation Delay Ratio
    --------------------------------------------------

    Propagation delay:

    Tp = 100 ms

    Compute:

    a = Tp / Tt

    = 100 / 10

    = 10

    --------------------------------------------------
    Step 3: Window Size Formula
    --------------------------------------------------

    For 100% utilization in sliding window protocol:

    W >= 1 + 2a

    Substitute value of a:

    W >= 1 + 2(10)

    W >= 21

    --------------------------------------------------
    Final Answer
    --------------------------------------------------

    Minimum window size required:

    W = 21 frames

    Correct Option: 21
    """

    Practice this question →

  105. Q105.GATE 2026

    Let 𝑓:ℝ→ℝ be defined as follows:

    f(𝑥)=(|𝑥|/2 −𝑥)(𝑥−|𝑥|/2 )

    Which of the following statements is/are true?

    1. A.

      f has a local maximum

    2. B.

      f has a local minimum

    3. C.

      f′ is continuous over ℝ

    4. D.

      f′ is not differentiable over ℝ

    Correct answer: A, C, D

    Solution

    For x ≥ 0, |x| = x, so f(x) = (x/2 - x)(x - x/2) = (-x/2)(x/2) = -x²/4. For x < 0, |x| = -x, so f(x) = (-x/2 - x)(x + x/2) = (-3x/2)(3x/2) = -9x²/4. Thus f(0) = 0 and f(x) < 0 for x ≠ 0 near the origin, so f has a local maximum at 0 and not a local minimum. Also, f′(x) = -9x/2 for x < 0, f′(0) = 0, and f′(x) = -x/2 for x > 0, hence f′ is continuous at 0. However, the left derivative of f′ at 0 is -9/2 and the right derivative is -1/2, so f′ is not differentiable at 0. Therefore, statements 1, 3, and 4 are true.

    Practice this question →

  106. Q106.GATE 2026

    Let 𝐺(𝑉,𝐸) be a simple, undirected graph. A vertex cover of 𝐺 is a subset V′⊆𝑉 such that for every (𝑢,𝑣)∈𝐸, 𝑢∈𝑉′or 𝑣∈𝑉′. Let the size of the smallest vertex cover in 𝐺 be 𝑘. Let 𝑆 be any vertex cover of size 𝑘.

    For a vertex 𝑣∈𝑉, which of the following constraints will always ensure that 𝑣∈𝑆 ?

    1. A.

      The degree of 𝑣 is at least 𝑘+1

    2. B.

      The vertex 𝑣 is on a path of length 𝑘+1

    3. C.

      The vertex 𝑣 is on a cycle of length 𝑘+1

    4. D.

      The vertex 𝑣 is a part of a clique of size 𝑘

    Correct answer: A

    Solution

    A vertex cover S of size k covers all edges in G. If a vertex v is not in S, then all its neighbors must be in S to cover the edges incident to v. This implies that |S| >= deg(v). Since |S| = k, we must have deg(v) <= k for v to potentially be excluded from S. Conversely, if deg(v) > k (or equivalently deg(v) >= k+1), it is impossible for v to be excluded from S because that would require more than k vertices in the cover. Therefore, any vertex with degree greater than k must be included in every minimum vertex cover of size k.

    Practice this question →

  107. Q107.GATE 2026

    Let 𝐺(𝑉,𝐸) be a simple, undirected, edge-weighted graph with unique edge weights. Which of the following statements about the minimum spanning trees (MST) of 𝐺 is/are true?

    1. A.

      In every cycle 𝐶 of 𝐺, the edge with the largest weight in 𝐶 is not in any MST

    2. B.

      In every cycle 𝐶 of 𝐺, the edge with the smallest weight in 𝐶 is in every MST

    3. C.

      For every vertex 𝑣 ∈𝑉, the edge with the largest weight incident on 𝑣 is not in any MST

    4. D.

      For every vertex 𝑣 ∈𝑉, the edge with the smallest weight incident on 𝑣 is in every MST

    Correct answer: A, D

    Solution

    Given:

    G(V,E) is a simple undirected weighted graph
    with unique edge weights.

    --------------------------------------------------
    Statement 1
    --------------------------------------------------

    "In every cycle C of G,
    the edge with the largest weight in C
    is not in any MST."

    This statement is TRUE.

    By the Cycle Property of MSTs:

    The maximum-weight edge in a cycle
    can never belong to a Minimum Spanning Tree.

    Since all edge weights are unique,
    the largest edge is uniquely determined.

    Therefore Statement 1 is TRUE.

    --------------------------------------------------
    Statement 2
    --------------------------------------------------

    "In every cycle C of G,
    the edge with the smallest weight in C
    is in every MST."

    This statement is FALSE.

    The minimum edge of a cycle is preferred,
    but it is not guaranteed to appear
    in every MST.

    Hence Statement 2 is FALSE.

    --------------------------------------------------
    Statement 3
    --------------------------------------------------

    "For every vertex v in V,
    the edge with the largest weight incident on v
    is not in any MST."

    This statement is FALSE.

    The largest incident edge may still be required
    to connect that vertex to the graph.

    Hence Statement 3 is FALSE.

    --------------------------------------------------
    Statement 4
    --------------------------------------------------

    "For every vertex v in V,
    the edge with the smallest weight incident on v
    is in every MST."

    This statement is TRUE.

    Consider the cut separating vertex v
    from all remaining vertices.

    The minimum-weight edge incident on v
    is the unique lightest edge crossing that cut.

    By the Cut Property of MSTs,
    this edge must belong to every MST.

    Hence Statement 4 is TRUE.

    --------------------------------------------------
    Final Answer
    --------------------------------------------------

    Statements 1 and 4 are TRUE.
    """

    Practice this question →

  108. Q108.GATE 2026

    Consider the following context-free grammar 𝐺.

    𝑆→𝑎𝑏𝑎𝐴𝐵𝐴𝑏𝑏𝑎

    𝐴→𝑎𝑎𝐵𝐵𝐴𝑏 | 𝑏𝐵𝑎𝑏𝑎𝑎

    𝐵→𝑎𝐵𝑏 | 𝑎𝑏

    In the above grammar, 𝑆 is the start symbol, 𝑎 and 𝑏 are terminal symbols, and 𝐴 and B are non-terminal symbols.

    Let 𝐿(𝐺) be the language generated by the grammar 𝐺. For a string 𝑠∈𝐿(𝐺), let n1(𝑠) be the number of 𝑎’s in 𝑠 and 𝑛2(𝑠) be the number of 𝑏’s in 𝑠.

    Which of the following statements is/are true?

    1. A.

      There is a string 𝑠∈𝐿(𝐺) such that 𝑛1(𝑠)<𝑛2(𝑠)

    2. B.

      For every string 𝑠∈𝐿(𝐺), 𝑛1(𝑠)≥𝑛2(𝑠)

    3. C.

      There is a string 𝑠∈𝐿(𝐺) such that 𝑛1(𝑠)>2𝑛2(𝑠)

    4. D.

      For every string 𝑠∈𝐿(𝐺), 𝑛1(𝑠)≤2𝑛2(𝑠)

    Correct answer: B, D

    Solution

    To determine the true statements, we analyze the balance of terminal symbols 'a' and 'b' in each production rule.

    First, consider non-terminal B. The productions are B → aBb | ab. In both cases, the number of 'a's equals the number of 'b's generated directly or recursively. Thus, for any string derived from B, n1 = n2.

    Next, analyze non-terminal A. Production 1 (aaBBAb) adds more 'a's than 'b's and includes A recursively. Production 2 (bBabaa) adds more 'a's than 'b's and includes B. Derivation shows that for any string from A, n1 > n2.

    Finally, analyze the start symbol S (ab a A B A b b a). It adds more 'a's than 'b's directly and includes two instances of A (where n1 > n2) and one B (n1 = n2). The total count confirms that for any string s in L(G), the number of 'a's is strictly greater than the number of 'b's.

    Based on this analysis, the statements corresponding to options 1 and 3 are true.

    Practice this question →

  109. Q109.GATE 2026

    Consider a system that has a cache memory unit and a memory management unit (MMU). The address input to the cache memory is a physical address. The MMU has a translation lookaside buffer (TLB). Assume that when a page is evicted from the main memory, the corresponding blocks in the cache are marked as invalid.

    For a given memory reference, which of the following sequences of events can NEVER happen?

    1. A.

      TLB miss, Page table hit, Cache hit

    2. B.

      TLB hit, Page table miss, Cache hit

    3. C.

      TLB miss, Page table miss, Cache hit

    4. D.

      TLB miss, Page table miss, Cache miss

    Correct answer: B, C

    Solution

    A TLB hit implies the page table entry is valid and present in memory. A Page Table Miss indicates the virtual address is unmapped, triggering a page fault. Without a valid physical translation from the MMU, the cache cannot be accessed successfully because it requires a physical address. Therefore, a Cache Hit is impossible during a Page Table Miss. Additionally, a valid TLB entry contradicts the condition of a Page Table Miss as they cannot both be true for the same address translation. Thus, sequences combining these events are logically impossible.

    Practice this question →

  110. Q110.GATE 2026

    An undirected, unweighted, simple graph 𝐺(𝑉,𝐸) is said to be 2-colorable if there exists a function 𝑐:𝑉→{0,1} such that for every (𝑢,𝑣)∈𝐸, 𝑐(𝑢)≠𝑐(𝑣). Which of the following statements about 2-colorable graphs is/are true?

    1. A.

      If 𝐺 is 2-colorable, then 𝐺 may contain cycles of odd length

    2. B.

      If 𝐺 is 2-colorable, then 𝐺 may contain cycles of even length

    3. C.

      An optimal algorithm for testing whether 𝐺 is 2-colorable runs in time Θ(|𝑉|+|𝐸|), if 𝐺 is represented as an adjacency list

    4. D.

      An optimal algorithm for testing whether 𝐺 is 2-colorable runs in time Θ(|𝐸|log|𝑉|), if 𝐺 is represented as an adjacency list

    Correct answer: B, C

    Solution

    Solution

    A graph is 2-colorable if adjacent vertices
    can be colored using two colors such that
    no two adjacent vertices have the same color.

    2-colorable graphs are exactly bipartite graphs.

    --------------------------------------------------
    Statement 1
    --------------------------------------------------

    "If G is 2-colorable,
    then G may contain cycles of odd length"

    This is FALSE.

    A bipartite graph cannot contain odd cycles.

    Hence Statement 1 is FALSE.

    --------------------------------------------------
    Statement 2
    --------------------------------------------------

    "If G is 2-colorable,
    then G may contain cycles of even length"

    This is TRUE.

    Example:
    A cycle of length 4 is bipartite.

    Hence Statement 2 is TRUE.

    --------------------------------------------------
    Statement 3
    --------------------------------------------------

    "An optimal algorithm for testing whether
    G is 2-colorable runs in time
    Theta(|V| + |E|),
    if G is represented as an adjacency list"

    This is TRUE.

    Using BFS or DFS,
    we can color the graph while traversing it.

    Each vertex and edge is processed once.

    Therefore time complexity is:

    Theta(|V| + |E|)

    --------------------------------------------------
    Statement 4
    --------------------------------------------------

    "An optimal algorithm for testing whether
    G is 2-colorable runs in time
    Theta(|E| log |V|)"

    This is FALSE.

    The optimal complexity is linear:

    Theta(|V| + |E|)

    Hence Statement 4 is FALSE.

    --------------------------------------------------
    Final Answer
    --------------------------------------------------

    Statements 2 and 3 are TRUE.
    """

    Practice this question →

  111. Q111.GATE 2026

    An ISP having an address block 202.16.0.0/15 assigns a block of 6000 IP addresses to a client, using the classless internet domain routing (CIDR) super-netting approach. Which of the following address blocks can be assigned by the ISP?

    1. A.

      202.16.0.0/19

    2. B.

      202.17.64.0/19

    3. C.

      202.16.32.0/19

    4. D.

      202.17.24.0/19

    Correct answer: A, B, C

    Solution

    The correct answers are A, B, and C.

    Step 1: Determine the Required Block Size

    The client requires 6000 IP addresses.

    In CIDR, address blocks must contain a power-of-2 number of addresses.

    • (2^{12} = 4096) (not sufficient)

    • (2^{13} = 8192) (sufficient)

    Hence, the client must be allocated a block of 8192 addresses.

    Since (8192 = 2^{13}), 13 bits are needed for host addresses.

    Therefore, the prefix length is:

    32 − 13 = 19

    So, the required subnet size is /19.

    Step 2: Determine the ISP's Address Range

    The ISP owns the block 202.16.0.0/15.

    A /15 network covers all addresses from:

    202.16.0.0 to 202.17.255.255

    All four options lie within this range.

    Step 3: Check Valid /19 Network Boundaries

    A /19 subnet mask is:

    255.255.224.0

    Since 224 = 11100000, the third octet increments in blocks of:

    256 − 224 = 32

    Therefore, valid /19 network addresses must have a third octet equal to:

    0, 32, 64, 96, 128, 160, 192, or 224

    Step 4: Evaluate Each Option

    A. 202.16.0.0/19

    • Third octet = 0

    • 0 is a valid multiple of 32

    Valid

    B. 202.17.64.0/19

    • Third octet = 64

    • 64 is a valid multiple of 32

    Valid

    C. 202.16.32.0/19

    • Third octet = 32

    • 32 is a valid multiple of 32

    Valid

    D. 202.17.24.0/19

    • Third octet = 24

    • 24 is not a multiple of 32

    • Therefore, it is not the starting address of a valid /19 subnet

    Invalid

    Hence, the correct options are:

    A. 202.16.0.0/19

    B. 202.17.64.0/19

    C. 202.16.32.0/19

    D. 202.17.24.0/19

    Practice this question →

  112. Q112.GATE 2026

    Let 𝐺 be an undirected graph, which is a path on 8 vertices. The number of matchings in 𝐺 is ______. (answer in integer)

    Correct answer: 34

    Solution

    For a path graph on nnn vertices, the number of matchings is:

    image.png

    Practice this question →

  113. Q113.GATE 2026

    Let X be a random variable which takes values in the set {1, 2, 3, 4, 5, 6, 7, 8}. Further, Pr(X = 1) = Pr(X = 2) = Pr(X = 5) = Pr(X = 7) = 1/6 and Pr(X = 3) = Pr(X = 4) = Pr(X = 6) = Pr(X = 8) = 1/12.

    The expected value of X, denoted by E[X], is equal to ___________. (rounded off to two decimal places)

    Correct answer: 4.24 to 4.26

    Solution

    E[X] = Σ x·Pr(X = x). For values 1, 2, 5, and 7, each probability is 1/6, so their contribution is (1 + 2 + 5 + 7)/6 = 15/6 = 2.50. For values 3, 4, 6, and 8, each probability is 1/12, so their contribution is (3 + 4 + 6 + 8)/12 = 21/12 = 1.75. Therefore, E[X] = 2.50 + 1.75 = 4.25. Rounded to two decimal places, the answer is 4.25.

    Practice this question →

  114. Q114.GATE 2026

    Consider a hard disk with a rotational speed of 15000 rpm. The time to move the read/write head from a track to its adjacent track is 1 millisecond. Initially, the head is on track 0. The number of sectors per track is 400. The sector size is 1024 bytes. It is necessary to transfer data from 10 randomly located sectors in each of the following tracks in the order: 5, 12 and 7.

    The total time for the data transfer (in milliseconds) from the hard disk is _________. (rounded off to one decimal place)

    Correct answer: 77.3

    Solution

    Solution

    Given:

    Rotational speed = 15000 rpm
    Adjacent track seek time = 1 ms
    Tracks accessed in order = 5, 12, 7
    Sectors per track = 400
    Sector size = 1024 bytes
    10 randomly located sectors are accessed per track

    --------------------------------------------------
    Step 1: Rotation Time
    --------------------------------------------------

    Time for one complete rotation:

    = 60 / 15000 seconds

    = 0.004 s

    = 4 ms

    Average rotational latency:

    = 4 / 2

    = 2 ms

    --------------------------------------------------
    Step 2: Seek Time
    --------------------------------------------------

    Track movement:

    0 -> 5 = 5 tracks
    5 -> 12 = 7 tracks
    12 -> 7 = 5 tracks

    Total tracks moved:

    = 5 + 7 + 5

    = 17 tracks

    Since adjacent-track seek time = 1 ms:

    Total seek time:

    = 17 ms

    --------------------------------------------------
    Step 3: Rotational Latency
    --------------------------------------------------

    Total sectors accessed:

    = 10 sectors/track × 3 tracks

    = 30 sectors

    Since sectors are randomly located,
    each sector requires average rotational latency.

    Average rotational latency per sector:

    = 2 ms

    Total rotational latency:

    = 30 × 2

    = 60 ms

    --------------------------------------------------
    Step 4: Transfer Time
    --------------------------------------------------

    400 sectors are transferred in one rotation.

    One rotation time = 4 ms

    Time per sector:

    = 4 / 400

    = 0.01 ms

    For 30 sectors:

    = 30 × 0.01

    = 0.3 ms

    --------------------------------------------------
    Final Calculation
    --------------------------------------------------

    Total time:

    = Seek Time + Rotational Latency + Transfer Time

    = 17 + 60 + 0.3

    = 77.3 ms

    --------------------------------------------------
    Final Answer
    --------------------------------------------------

    77.3 ms
    """

    Practice this question →

  115. Q115.GATE 2026

    The EX stage of a pipelined processor performs the memory read operations for LOAD instructions, and the operations for the arithmetic and logic instructions. Let t𝐸𝑋 denote the time taken by the EX stage to perform the operation for an instruction. For each instruction type, the values of 𝑡𝐸𝑋 and M (the number of instructions of that type in a sequence of 100 instructions for a program P), are given in the table below.

    The duration of the pipeline clock cycle is 1 nanosecond. Assume that the latch time for the interstage buffers in the pipeline is negligible.

    image.png

    When program P is executed, the number of clock cycles for which the pipeline is stalled due to structural hazards in the EX stage is ______. (answer in integer)

    Correct answer: 95

    Solution

    The pipeline clock cycle is 1 ns. The EX stage is a shared resource. If an instruction takes t_EX > 1 ns, the EX stage is occupied for multiple cycles, causing structural hazards (stalls) for subsequent instructions.

    Number of cycles occupied = ceil(t_EX / 1 ns). Stall cycles per instruction = (Occupied Cycles - 1). We calculate total stalls by summing (M * Stalls) for each instruction type.

    • LOAD: ceil(1.8) = 2 cycles -> 1 stall * 15 = 15

    • IMUL: ceil(1.5) = 2 cycles -> 1 stall * 10 = 10

    • IDIV: ceil(2.5) = 3 cycles -> 2 stalls * 5 = 10

    • FADD: ceil(1.7) = 2 cycles -> 1 stall * 10 = 10

    • FSUB: ceil(1.7) = 2 cycles -> 1 stall * 5 = 5

    • FMUL: ceil(2.8) = 3 cycles -> 2 stalls * 15 = 30

    • FDIV: ceil(3.2) = 4 cycles -> 3 stalls * 5 = 15

    • Others: ceil(<1.0) = 1 cycle -> 0 stalls * 35 = 0

    Total stall cycles = 15 + 10 + 10 + 10 + 5 + 30 + 15 = 95.

    Practice this question →

  116. Q116.GATE 2026

    Consider the recursive functions represented by the following code segment:

    image.png

    The smallest positive integer n for which foo(n) returns 5 is ______. (answer in integer) Note: Ignore syntax errors (if any) in the function.

    Correct answer: 65536

    Solution

    First, analyze the function bar(n). It returns the number of times n can be divided by 2 before reaching 1. Mathematically, bar(n) = floor(log2(n)). For example, bar(1)=0, bar(2)=1, bar(4)=2, bar(8)=3.

    Next, analyze foo(n). It adds 1 for each recursive step: foo(n) = 1 + foo(bar(n)). We want foo(n) = 5.

    This implies foo(bar(n)) = 4, foo(bar(bar(n))) = 3, foo(bar(bar(bar(n)))) = 2, and foo(bar(bar(bar(bar(n))))) = 1.

    Since foo(1) = 1, we need bar(bar(bar(bar(n)))) = 1.

    Working backwards: bar(x) = 1 for x in [2, 3]. bar(y) = 2 for y in [4, 7]. bar(z) = 3 for z in [8, 15].

    Continuing, bar(w) = 4 for w in [16, 31] and bar(w) = 15 for w in [32768, 65535]. So bar(n) must be in [16, 65535].

    Finally, bar(n) = 16 for n in [65536, 131071]. The smallest positive integer n is 65536.

    Practice this question →

  117. Q117.GATE 2026

    The following sequence corresponds to the preorder traversal of a binary search tree 𝑇:

    50, 25, 13, 40, 30, 47, 75, 60, 70, 80, 77

    The position of the element 60 in the postorder traversal of 𝑇 is ______. (answer in integer) Note: The position begins with 1.

    Correct answer: 7

    Solution

    Step 1: Reconstruct the Binary Search Tree (BST) using the given preorder traversal: 50, 25, 13, 40, 30, 47, 75, 60, 70, 80, 77.

    Step 2: Identify the root (50). Left subtree contains values < 50: 25, 13, 40, 30, 47. Right subtree contains values > 50: 75, 60, 70, 80, 77.

    Step 3: Recursively build subtrees. Left root is 25. Right root is 75. Continue recursively to form the full tree structure.

    Step 4: Generate postorder traversal (Left, Right, Root). Sequence: 13, 30, 47, 40, 25, 70, 60, 77, 80, 75, 50.

    Step 5: Locate element 60 in the sequence. It is at the 7th position.

    Practice this question →

  118. Q118.GATE 2026

    Consider the following program snippet. Assume that the program compiles and runs successfully. Further, assume that the fork() system call is always successful in creating a process.

    image.png

    The total number of times that the printf statement gets executed is ________. (answer in integer)

    Correct answer: 4

    Solution

    The correct answer is 4. Trace: 1. P0 (i=0): Forks. Parent (P0) breaks, prints (1). Child (C1) continues. 2. C1 (i=1): Forks. Parent (C1) breaks, prints (2). Child (C2) continues. 3. C2 (i=2): Forks. Parent (C2) breaks, prints (3). Child (C3) continues. 4. C3 (i=3): Loop condition (3 < 3) is false. Loop terminates. C3 prints (4). Total executions: 4.

    Practice this question →

  119. Q119.GATE 2026

    Consider a CPU that has to execute two types of processes. The first type, Actuators (A), requires a CPU burst of 6 seconds. The second type, Controllers (C), requires a CPU burst of 8 seconds. A new process of type A arrives at time 𝑡 = 10, 20, 30, 40, and 50 (in seconds). Similarly, a new process of type C arrives at time 𝑡 = 11, 22, 33, 44, and 55 (in seconds). The CPU scheduling policy is First Come First Serve (FCFS). The first process of type A starts running at 𝑡 = 10 seconds. The average waiting time (in seconds) for the 10 processes is ___________. (rounded off to one decimal place)

    Correct answer: 9.5

    Solution

    Step-by-Step Solution

    We need to calculate the waiting time for each of the 10 processes using the First Come First Serve (FCFS) scheduling policy. Waiting Time = Start Time - Arrival Time.

    Process Timeline Analysis

    1. Process A1: Arrives at 10s. Starts at 10s. Burst = 6s. Finishes at 16s. Waiting Time = 10 - 10 = 0s.

    2. Process C1: Arrives at 11s. CPU is busy with A1 until 16s. Starts at 16s. Burst = 8s. Finishes at 24s. Waiting Time = 16 - 11 = 5s.

    3. Process A2: Arrives at 20s. CPU is busy with C1 until 24s. Starts at 24s. Burst = 6s. Finishes at 30s. Waiting Time = 24 - 20 = 4s.

    4. Process C2: Arrives at 22s. CPU is busy with A2 until 30s. Starts at 30s. Burst = 8s. Finishes at 38s. Waiting Time = 30 - 22 = 8s.

    5. Process A3: Arrives at 30s. CPU is busy with C2 until 38s. Starts at 38s. Burst = 6s. Finishes at 44s. Waiting Time = 38 - 30 = 8s.

    6. Process C3: Arrives at 33s. CPU is busy with A3 until 44s. Starts at 44s. Burst = 8s. Finishes at 52s. Waiting Time = 44 - 33 = 11s.

    7. Process A4: Arrives at 40s. CPU is busy with C3 until 52s. Starts at 52s. Burst = 6s. Finishes at 58s. Waiting Time = 52 - 40 = 12s.

    8. Process C4: Arrives at 44s. CPU is busy with A4 until 58s. Starts at 58s. Burst = 8s. Finishes at 66s. Waiting Time = 58 - 44 = 14s.

    9. Process A5: Arrives at 50s. CPU is busy with C4 until 66s. Starts at 66s. Burst = 6s. Finishes at 72s. Waiting Time = 66 - 50 = 16s.

    10. Process C5: Arrives at 55s. CPU is busy with A5 until 72s. Starts at 72s. Burst = 8s. Finishes at 80s. Waiting Time = 72 - 55 = 17s.

    Calculation of Average Waiting Time

    Sum of Waiting Times = 0 + 5 + 4 + 8 + 8 + 11 + 12 + 14 + 16 + 17 = 95 seconds.

    Total number of processes = 10.

    Average Waiting Time = Total Waiting Time / Total Processes = 95 / 10 = 9.5 seconds.

    The average waiting time is 9.5 seconds.

    Practice this question →

  120. Q120.GATE 2026

    Consider a relational database schema with a relation 𝑅(𝐴,𝐵,𝐶,𝐷). If {𝐴,𝐵} and {𝐴,𝐶} are the only two candidate keys of the relation 𝑅, then the number of superkeys of relation 𝑅 is ______. (answer in integer)

    Correct answer: 6

    Solution

    A superkey is any set of attributes that contains at least one candidate key. The relation R has attributes {A, B, C, D}.

    Candidate keys are {A, B} and {A, C}. Superkeys containing {A, B} are formed by adding any subset of remaining attributes {C, D}.

    There are 2^2 = 4 such superkeys: {A, B}, {A, B, C}, {A, B, D}, {A, B, C, D}.

    Similarly, superkeys containing {A, C} are formed by adding any subset of remaining attributes {B, D}. There are 2^2 = 4 such superkeys.

    The intersection contains superkeys with both {A, B} and {A, C}, which means {A, B, C} plus subsets of {D}. There are 2^1 = 2 such superkeys.

    Total superkeys = (Superkeys with {A, B}) + (Superkeys with {A, C}) - (Intersection) = 4 + 4 - 2 = 6.

    Answer: 6

    Practice this question →

  121. Q121.GATE 2026

    Let 𝐿1 and 𝐿2 be two languages over a finite alphabet, such that 𝐿1∩𝐿2 and 𝐿2 are regular languages. Which of the following statements is/are always true?

    1. A.

      L1 is regular

    2. B.

      L1∪𝐿2 is regular

    3. C.

      L2' is context-free

    4. D.

      L1 is context-free

    Correct answer: C

    Solution

    Given that L₂ is a regular language and the intersection L₁ ∩ L₂ is also regular.

    Since every regular language is a context-free language, the intersection L₁ ∩ L₂ must be context-free. Therefore, the statement asserting that L₁ ∩ L₂ is context-free (Option C) is always true.

    To verify why other options are not always true, consider the counter-example where L₂ = ∅ (the empty set). The empty set is regular. In this case, L₁ ∩ L₂ = ∅, which satisfies the condition regardless of what L₁ is. This means L₁ does not have to be regular or context-free, disproving options claiming constraints on L₁. Similarly, the union L₁ ∪ L₂ = L₁ in this case, so it is not necessarily regular.

    Practice this question →

  122. Q122.GATE 2026

    Consider the following pseudocode for depth-first search (DFS) algorithm which takes a directed graph 𝐺(𝑉,𝐸) as input, where 𝑑[𝑣] and 𝑓[𝑣] are the discovery time and finishing time, respectively, of the vertex 𝑣 ∈𝑉.

    image.png

    Suppose that the input directed graph 𝐺(𝑉,𝐸) is a directed acyclic graph (DAG). For an edge (𝑢,𝑣)∈𝐸, which of the following options will NEVER be correct?

    1. A.

      𝑑[𝑢]<𝑑[𝑣]<𝑓[𝑣]<𝑓[𝑢]

    2. B.

      𝑑[𝑣]<𝑑[𝑢]<𝑓[𝑢]<𝑓[𝑣]

    3. C.

      𝑑[𝑣]<𝑓[𝑣]<𝑑[𝑢]<𝑓[𝑢]

    4. D.

      𝑑[𝑢]<𝑑[𝑣]<𝑓[𝑢]<𝑓[𝑣]

    Correct answer: B, D

    Solution

    In Depth-First Search (DFS), the discovery time $d[v]$ and finishing time $f[v]$ for any vertex $v$ satisfy $d[v] < f[v]$. The relationship between intervals $[d[u], f[u]]$ and $[d[v], f[v]]$ for any two vertices is governed by the Parenthesis Theorem: the intervals are either disjoint or one is contained within the other.

    Analysis of Edge Types

    For an edge $(u, v) \in E$ in a DAG:

    • Tree/Forward Edge: $v$ is a descendant of $u$. Interval of $v$ is inside $u$. Order: $d[u] < d[v] < f[v] < f[u]$. (Option A is possible)

    • Back Edge: $u$ is a descendant of $v$. This implies a cycle. Order: $d[v] < d[u] < f[u] < f[v]$. (Option B is impossible in a DAG)

    • Cross Edge: $u$ and $v$ are in different subtrees. Intervals are disjoint. Order: $d[v] < f[v] < d[u] < f[u]$ (if $v$ finished first). (Option C is possible)

    Why Option D is Impossible

    Option D suggests $d[u] < d[v] < f[u] < f[v]$. This implies that the interval $[d[u], f[u]]$ partially overlaps with $[d[v], f[v]]$. The Parenthesis Theorem states that DFS intervals cannot partially overlap; they must be either completely disjoint or completely nested. Therefore, this ordering is structurally impossible in any DFS traversal.

    Thus, the options that will NEVER be correct are B and D.

    Practice this question →

  123. Q123.GATE 2026

    Consider a Boolean function F with the following minterm expression:

    F(𝑃,𝑄,𝑅,𝑆)= ∑𝑚 (1,2,3,4,5,7,10,12,13,14)

    Which of the following options is/are the minimal sum-of-products expression(s) of F ?

    Solution

    Construct a K-map for F(P,Q,R,S) with minterms 1, 2, 3, 4, 5, 7, 10, 12, 13, 14.

    Identify Prime Implicants (PIs):

    - Group 1: m1, m3, m5, m7 -> Term: P'S

    - Group 2: m4, m5, m12, m13 -> Term: Q\bar{R}

    - Remaining minterms to cover: 2, 10, 14.

    - Cover m2: Use PI \bar{P}\bar{Q}R (covers 2,3).

    - Cover m10, m14: Use PI PR\bar{S} (covers 10,14).

    The minimal SOP is P'S + Q\bar{R} + \bar{P}\bar{Q}R + PR\bar{S}, which matches Option 1.

    Practice this question →

  124. Q124.GATE 2026

    Consider a relational database schema with two relations 𝑅(𝑃,𝑄) and 𝑆(𝑋,𝑌). Let 𝐸 = {⟨𝑢⟩∣∃𝑣 ∃𝑤 ⟨𝑢,𝑣⟩∈𝑅 ∧ ⟨𝑣,𝑤⟩ ∈𝑆} be a tuple relational calculus expression.

    Which one of the following relational algebraic expressions is equivalent to 𝐸 ?

    Solution

    To find the equivalent relational algebra expression, we analyze the Tuple Relational Calculus (TRC) expression:

    E = { ⟨u⟩ | ∃v ∃w (⟨u, v⟩ ∈ R ∧ ⟨v, w⟩ ∈ S) }

    1. Identify Attributes: Relation R has attributes (P, Q) and S has attributes (X, Y).

    2. Map Variables: The tuple ⟨u, v⟩ ∈ R implies u corresponds to P and v corresponds to Q. The tuple ⟨v, w⟩ ∈ S implies v corresponds to X and w corresponds to Y.

    3. Determine Join Condition: The variable v is common to both relations. Thus, the join condition is R.Q = S.X.

    4. Determine Projection: The result is projected on u, which corresponds to attribute P of relation R.

    5. Construct Expression: The equivalent expression is Π_P (S ⋈_{S.X=R.Q} R) or Π_P (R ⋈_{R.Q=S.X} S).

    Option B matches this structure: Π_P (S ⋈_{S.X=R.Q} R).

    Practice this question →

  125. Q125.GATE 2026

    Consider the control flow graph shown in the figure.

    image.png

    Which one of the following options correctly lists the set of redundant expressions (common subexpressions) in the basic blocks B4 and B5? Note: All the variables are integers.

    1. A.

      B4: { 𝑏+𝑖 }

      B5: { 𝑐+𝑚 }

    2. B.

      B4: { 𝑔∗𝑘 }

      B5: { 𝑐+𝑚 }

    3. C.

      B4: { 𝑔∗𝑘, 𝑏+𝑖 }

      B5: { }

    4. D.

      B4: { 𝑔∗𝑘 }

      B5: { }

    Correct answer: D

    Solution

    Analysis of Redundant Expressions

    A redundant expression (or common subexpression) in a basic block is one that has been computed previously along all paths leading to the current point, and the operands have not been modified since that computation.

    1. Analysis of Basic Block B4

    Predecessors of B4 are B2 and B3.

    • Expression g*k: Computed in B2 (a = g*k) and B3 (t = g*k). Neither block modifies g or k. Thus, g*k is available at the entry of B4.

    • Expression b+i: Computed in B1. However, in path B1 -> B3 -> B4, the variable b is modified in B3 (b = c+m). Thus, b+i is not available along all paths.

    Conclusion for B4: The only redundant expression is { g*k }.

    2. Analysis of Basic Block B5

    Predecessor of B5 is B4.

    Expression c+m: Computed in B3 (b = c+m). However, it is not computed in B2. Since it is not available along the path through B2, it is not redundant in B5.

    Conclusion for B5: No redundant expressions { }.

    Final Answer

    B4: { g*k }, B5: { }

    Practice this question →

  126. Q126.GATE 2026

    Consider a 2-bit saturating up/down counter that performs the saturating up count when the input P is 0, and the saturating down count when P is 1. The Next State table of the counter is as shown. The counter is built as a synchronous sequential circuit using D flip-flops.

    image.png

    Which one of the following options corresponds to the expressions for the inputs of the D flip-flops,𝐷1 and 𝐷0?

    Solution

    The correct option is B. By analyzing the state table for the 2-bit saturating up/down counter: For D1 (Q1+), the minterms are 1, 2, 3, 7. Simplifying yields D1 = P'Q1 + P'Q0 + Q1Q0. For D0 (Q0+), the minterms are 0, 2, 3, 6, 7. Simplifying yields D0 = Q1 + P'Q0'. Option B matches these derived expressions.

    Practice this question →

  127. Q127.GATE 2026

    Consider the following program in C:

    image.png

    The output of the program is _________. (answer in integer)

    Note: Assume that the program compiles and runs successfully.

    Correct answer: 9

    Solution

    1. In main(), i = 9 and j = 10. func(9, 10) is called.

    2. Inside func(), parameter i = 9, j = 10.

    3. if (9 < 10) is true. int i = 0 declares a new local variable i, shadowing the parameter i.

    4. The while loop modifies the new local i and parameter j. Parameter i remains 9.

    5. After the if block, the new local i is out of scope. printf prints the parameter i, which is 9.

    Practice this question →

  128. Q128.GATE 2026

    Consider the function 𝑓:ℝ→ℝ defined as follows:

    image.png

    where 𝑐1 ,𝑐2∈ℝ.

    If 𝑓 is continuous at 𝑥 = 0, then 𝑐1+𝑐2 = _________. (answer in integer)

    Correct answer: 3

    Solution

    For x ≤ 0, f(x) = 3, so f(0) = 3 and the left-hand limit at 0 is 3. For x > 0, f(x) = c₁eˣ - c₂ ln(1/x). As x → 0+, ln(1/x) → ∞. For the right-hand limit to be finite, we must have c₂ = 0. Then the right-hand limit becomes c₁e⁰ = c₁. Continuity at x = 0 requires c₁ = 3. Hence c₁ + c₂ = 3 + 0 = 3.

    Practice this question →

  129. Q129.GATE 2026

    Consider the following Boolean expression of a function F :

    F(𝑃,𝑄)= (𝑃'+𝑄)⊕(𝑃'𝑄)

    Which of the following expressions is/are equivalent to F ?

    1. A.

      (P⊕𝑄)'

    2. B.

      P⊕𝑄

    3. C.

      P'⊕𝑄

    4. D.

      P'⊕𝑄'

    Correct answer: A, C

    Solution

    Given F(P, Q) = (P' + Q) ⊕ (P'Q). Using the definition A ⊕ B = AB' + A'B, we substitute A = (P' + Q) and B = P'Q.

    The expression becomes (P' + Q)(P'Q)' + (P' + Q)'(P'Q). Applying De Morgan's laws: (P'Q)' = P + Q' and (P' + Q)' = PQ'. Substituting these back, we get F = (P' + Q)(P + Q') + PQ'(P'Q).

    The second term simplifies to 0 because P'P = 0. Expanding the first term: P'P + P'Q' + QP + QQ'. Since P'P = 0 and QQ' = 0, this simplifies to P'Q' + PQ.

    This expression represents the XNOR operation (P ⊙ Q). Thus, F is equivalent to (P ⊕ Q)' and also P' ⊕ Q.

    Practice this question →

  130. Q130.GATE 2026

    Consider the following Boolean expression of a function F :

    F(𝑃,𝑄)= (𝑃'+𝑄)⊕(𝑃'𝑄)

    Which of the following expressions is/are equivalent to F ?

    1. A.

      (P⊕𝑄)'

    2. B.

      𝑃⊕𝑄

    3. C.

      𝑃'⊕𝑄

    4. D.

      𝑃⊕𝑄'

    Correct answer: A, C, D

    Solution

    Given:

    F(P,Q) = (P' + Q) xor (P'Q)

    Using XOR identity:

    A xor B = AB' + A'B

    Let A = (P' + Q) and B = (P'Q).

    F = (P' + Q)(P'Q)' + (P' + Q)'(P'Q)

    Now,

    (P'Q)' = P + Q'

    (P' + Q)' = PQ'

    So,

    F = (P' + Q)(P + Q') + (PQ')(P'Q)

    Expand the first term:

    (P' + Q)(P + Q') = P'P + P'Q' + PQ + QQ'

    Since P'P = 0 and QQ' = 0, this becomes:

    P'Q' + PQ

    The second term is:

    (PQ')(P'Q) = PP'QQ' = 0

    Therefore,

    F = P'Q' + PQ

    This is XNOR. Hence:

    (P xor Q)' = P'Q' + PQ

    Also,

    P' xor Q = P'Q' + PQ

    P xor Q' = PQ + P'Q'

    Thus, the equivalent expressions are options A, C, and D.

    Final Answer: A, C and D.

    Practice this question →

  131. Q131.GATE 2026

    Consider an array A = [10, 7, 8, 19, 41, 35, 25, 31]. Suppose the merge sort algorithm is executed on array A to sort it in increasing order. The merge sort algorithm will carry out a total of 7 merge operations. A merge operation on sorted left array L and sorted right array R is said to be void if the output of the merge operation is the elements of array L followed by the elements of array R.

    The number of void merge operations among these 7 merge operations is __________. (answer in integer)

    Correct answer: 3

    Solution

    The array A = [10, 7, 8, 19, 41, 35, 25, 31] has n=8 elements. Merge sort performs n-1 = 7 merge operations.

    Level 1 Merges (4 operations):

    1. Merge [10] and [7]: 10 > 7, not void. 2. Merge [8] and [19]: 8 < 19, void. 3. Merge [41] and [35]: 41 > 35, not void. 4. Merge [25] and [31]: 25 < 31, void.

    Level 2 Merges (2 operations):

    5. Merge [7, 10] and [8, 19]: max(10) > min(8), not void. 6. Merge [35, 41] and [25, 31]: max(41) > min(25), not void.

    Level 3 Merge (1 operation):

    7. Merge [7, 8, 10, 19] and [25, 31, 35, 41]: max(19) < min(25), void.

    Total void merge operations = 3.

    A video solution is available for this question — log in and enroll to watch it.

    Practice this question →

  132. Q132.GATE 2026

    Consider the following grammar where 𝑆 is the start symbol, and 𝑎 and 𝑏 are terminal symbols.
    𝑆 → 𝑎𝑆𝑏𝑆 ∣ 𝑏𝑆 ∣ ϵ
    Which of the following statements is/are true?

    1. A.

      (A) The grammar is ambiguous

    2. B.

      (B) The string 𝑎𝑏𝑏 has two distinct derivations in this grammar

    3. C.

      (C) The string 𝑎𝑏𝑎𝑏 has only one rightmost derivation

    4. D.

      (D) The language generated by the grammar is undecidable

    Correct answer: A, B, C

    Solution

    SOLUTION:

    OPTION A) TRUE. The grammar is ambiguous.

    A grammar is ambiguous if and only if there exists at least one string in L(G) for which the grammar produces more than one parse tree.

    String abb ∈ L(G) and G produces more than one parse tree for abb:

    image.png

    OPTION B) TRUE. The string abb has two distinct derivations in this grammar.

    1st derivation:

    S ⇒ aSbS
    ⇒ abS
    ⇒ abbS
    ⇒ abb

    2nd derivation:

    S ⇒ aSbS
    ⇒ abSbS
    ⇒ abbS
    ⇒ abb

    Note that the question is not asking for rightmost (or leftmost) derivations. It is just asking about derivations. There are more than 2 derivations of the string abb, but the question is asking for the existence of at least two derivations.

    OPTION C) TRUE. The string abab has only one rightmost derivation.

    S ⇒rmd aSbS
    ⇒rmd aSbaSbS
    ⇒rmd aSbaSb
    ⇒rmd aSbab
    ⇒rmd abab

    At each step, the next terminal forces a unique production choice, so no alternative rightmost derivation exists.

    This fact can also be seen using the parse tree. There is only 1 parse tree that yields the string abab. Therefore, only 1 rightmost derivation exists. For any CFG, the number of rightmost derivations is the same as the number of parse trees for a given string.

    OPTION D) False. The language generated by the grammar is undecidable.

    This is incorrect. The given grammar is a context-free grammar (CFG), and every language generated by a CFG is a context-free language. Membership testing for context-free languages is decidable.

    Therefore, the language generated by the grammar is decidable, not undecidable.

    Practice this question →

  133. Q133.GATE 2026

    Consider the function f: R--> R

    image.png

    where 𝑐1 , 𝑐2 ∈ ℝ
    If 𝑓 is continuous at 𝑥 = 0, then 𝑐1 + 𝑐2 = _________.

    Correct answer: 3

    Solution

    For x ≤ 0, f(x) = 3, so f(0) = 3 and the left-hand limit at 0 is 3. For x > 0, f(x) = c₁eˣ - c₂ ln(1/x). As x → 0+, ln(1/x) → ∞. For the right-hand limit to be finite, c₂ must be 0. Then the right-hand limit becomes c₁e⁰ = c₁. Continuity at x = 0 requires c₁ = 3. Therefore c₁ + c₂ = 3 + 0 = 3.

    Practice this question →

  134. Q134.GATE 2026

    Consider the following two syntax-directed definitions SDD1 and SDD2 for type declarations.

    image.png

    𝐷 is the start symbol, and 𝑖𝑛𝑡, 𝑓𝑙𝑜𝑎𝑡 and 𝑖𝑑 are the three terminals. The non-terminal 𝑉1 is the same as 𝑉 and the non-terminal 𝐷1 is the same as 𝐷. Here, the subscript is used to differentiate the grammar symbols on the two sides of a production. The function 𝑝𝑢𝑡 updates the symbol table with the type information for an identifier. Let P and Q be the languages specified by grammars G1 and G2, respectively.
    Which of the following statements is/are true?

    1. A.

      The languages P and Q are the same

    2. B.

      SDD2 is S-attributed and contains only synthesized attributes

    3. C.

      SDD1 is L-attributed and contains only inherited attributes

    4. D.

      The specifications of SDD1 and SDD2 are such that the same entries get added to the symbol table

    Correct answer: A, B, D

    Solution

    Both grammars generate declarations of the form type followed by one or more identifiers.

    Statement A is true. In G1, D → T V and V → V₁ id | id generate one or more identifiers after a type. In G2, D → D₁ id | T id generates the same strings by left recursion. Hence P = Q.

    Statement B is true. In SDD2, every type attribute is synthesized: T.type is set from the terminal int/float, and D.type is computed from T.type or D₁.type. No inherited attribute is used, so SDD2 is S-attributed.

    Statement C is false. SDD1 is L-attributed because the inherited attribute V.type is passed to V₁.type in a left-to-right manner. However, it does not contain only inherited attributes; T.type and D.type are synthesized attributes.

    Statement D is true. In both SDDs, each identifier receives the type computed from the declaration, so the same put(id.entry, type) entries are added to the symbol table.

    Therefore, the correct options are A, B, and D.

    Practice this question →

  135. Q135.GATE 2026
    image.png

    match the following anc select the correct options .

    1. A.

      (A) I – L, II – M, III – N

    2. B.

      (B) I – M, II – L, III – N

    3. C.

      (C) I – N, II – M, III – L

    4. D.

      (D) I – L, II – N, III – M

    Correct answer: A

    Solution

    Inorder traversal (I) visits the left subtree, then the node, and finally the right subtree, which corresponds to sequence L. Preorder traversal (II) visits the node first, followed by left and right subtrees, matching sequence M. Postorder traversal (III) visits the left subtree, then the right subtree, and ends with the node, matching sequence N. Therefore, the correct pairing is I-L, II-M, and III-N.

    Practice this question →