CS/IT Gate Yearwise
CS/IT Gate 2026 (Set 2)
CS/IT Gate 2025 (Set 1)
CS/IT Gate 2025 (Set 2)
CS/IT Gate 2024 (Set 1)
CS/IT Gate 2024 (Set 2)
CS/IT Gate 2023
CS/IT Gate 2022
CS/IT Gate 2021 (Set 1)
CS/IT Gate 2021 (Set 2)
CS/IT Gate 2020
CS/IT Gate 2019
CS/IT Gate 2018
CS/IT Gate 2017 (Set 1)
CS/IT Gate 2017 (Set 2)
CS/IT Gate 2016 (Set 1)
CS/IT Gate 2016 (Set 2)
CS/IT Gate 2015 (Set 1)
CS/IT Gate 2015 (Set 2)
CS/IT Gate 2015 (Set 3)
CS/IT Gate 2014 (Set 1)
CS/IT Gate 2014 (Set 2)
CS/IT Gate 2014 (Set 3)
CS and IT Gate 2026 Set-1 Questions with Answer
Ques 53 GATE 2026 SET-1
In the 2020 summer Olympics' Javelin throw finals, Neeraj Chopra exhibited a spectacular performance to win the gold medal. The silver medal was won by Jakub Vadlejch and the bronze medal was won by Vitezlav Vesely. There were six rounds of throws with each athlete having one throw per round. The best of all the throws of each athlete is considered for the medal. Following were the observations about the throws:
i. The first and second rounds were dominated by Neeraj Chopra with a gold medal performance in his second throw, while the other two athletes did not have any medal winning throws in these rounds.
ii. The throws in the last round by both Jakub Vadlejch and Vitezlav Vesely were fouls and were not considered for scoring.
iii. After four rounds, Vitezlav Vesely was in the second position and could not improve upon his best throw in the succeeding rounds.
iv. In the fourth round, the throw by Jakub Vadlejch was the best in that round.
In which round did Vitezlav Vesely have his best throw?
Ques 54 GATE 2026 SET-1
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.
int main () {
int i;
for (i = 0; i < 3; i++){
if (fork() == 0){
continue;
}
break;
}
printf("Hello!");
return 0;
}The total number of times that the
printf statement gets executed is ________. (answer in integer)
Ques 55 GATE 2026 SET-1
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 t = 10, 20, 30, 40, and 50 (in seconds). Similarly, a new process of type C arrives at time t = 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 t = 10 seconds.
The average waiting time (in seconds) for the 10 processes is ___________. (rounded off to one decimal place)
Ques 56 GATE 2026 SET-1
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)
The correct answer is 6.
This is a classic deadlock avoidance problem. The standard formula to find the minimum number of resource instances required to guarantee a deadlock-free environment is:
Minimum k = n × (m − 1) + 1
Where:
n = number of processes = 5
m = maximum instances any process can hold = 2
So: k = 5 × (2 − 1) + 1 = 5 × 1 + 1 = 6
Why does this work? The worst-case deadlock scenario is when every process holds (m−1) instances and is waiting for one more. With 5 processes each holding 1 instance, that''s 5 instances total consumed and every process stuck waiting. If k = 5, all instances are held with no process able to proceed - deadlock.
But with k = 6, even if all 5 processes each hold 1 instance (5 used), there is still 1 remaining instance. That extra instance can be given to one process, allowing it to acquire its second instance, complete, and release both. This chain reaction ensures all processes eventually finish - no deadlock possible.
Ques 57 GATE 2026 SET-1
With respect to deadlocks in an operating system, which of the following statements is/are FALSE?
The correct answer is Option A - the false statement.
The question asks which statement about deadlock is FALSE. Let''s evaluate each:
Option A - An assignment edge is marked from a process to a resource: FALSE. This is the wrong direction. In a Resource Allocation Graph (RAG):
- A request edge goes from Process → Resource (process is waiting for it).
- An assignment edge goes from Resource → Process (resource is held by the process).
Option A has it backwards - it describes a request edge, not an assignment edge. So Option A is false and is the correct answer.
Option B - A safe state guarantees all processes can finish without deadlock: TRUE. A safe state means there exists at least one safe sequence in which every process can get its required resources and complete. The OS will never enter deadlock from a safe state.
Option C - Deadlock can be prevented by not allowing hold and wait: TRUE. Deadlock requires all four conditions simultaneously - mutual exclusion, hold and wait, no preemption, and circular wait. Eliminating hold and wait (e.g., requiring processes to acquire all resources before starting) breaks the deadlock formation chain.
Option D - Banker''s algorithm is used to prevent deadlock: Broadly TRUE in this context, though technically Banker''s is a deadlock avoidance algorithm (not prevention). It checks resource requests against system state to ensure the system stays in a safe state, effectively stopping deadlock before it occurs.
The clear false statement is Option A - assignment edges run from resource to process, not the other way around.
Ques 58 GATE 2026 SET-1
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?
Ques 59 GATE 2026 SET-1
Consider the recursive functions represented by the following code segment:
int bar(int n){
if (n == 1) return 0;
else return 1 + bar(n/2);
}
int foo(int n){
if (n == 1) return 1;
else return 1 + foo(bar(n));
}The smallest positive integer n for which
foo(n) returns 5 is ______. (answer in integer)Note: Ignore syntax errors (if any) in the function.
Ques 60 GATE 2026 SET-1
Consider the following program in C:
#include <stdio.h>
void func(int i, int j) {
if(i < j) {
int i = 0;
while (i < 10) {
j += 2;
i++;
}
}
printf("%d", i);
}
int main() {
int i = 9, j = 10;
func(i, j);
return 0;
}
The output of the program is _________. (answer in integer)
Note: Assume that the program compiles and runs successfully.
Ques 61 GATE 2026 SET-1
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?
Ques 62 GATE 2026 SET-1
Consider the following grammar where 𝑆 is the start symbol, and 𝑎 and 𝑏 are
terminal symbols.
S → aSbS | bS | ε
w
which of the following statements is/are true?
Option A - True.
Rightmost derivation of "abab":
S → aSbS → aSb(bS) → aSb(b) → a(aSbS)b(b) → a(aSb)bb → a(a)bbb — this does not work.
Correct rightmost derivation:
S → aSbS → aSb(ε) → aSb → a(aSbS)b → a(aSb(ε))b → a(aSb)b → a(a(ε)b)b = aabb — not "abab"
S → aSbS → aSb(bS) → aSb(b(ε)) → aSbb → not "abab"
S → aSbS → a(ε)bS → abS → ab(aSbS) → ab(a(ε)b(ε)) → abab
Only one such rightmost derivation exists for "abab". True.
Option B - False.
The language generated by a context free grammar is always decidable (it is recursively enumerable and decidable using CYK algorithm). False.
Option C - True.
A grammar is ambiguous if any string has more than one parse tree (or leftmost/rightmost derivation).
For "abb", two derivations exist (shown in Option D below), so the grammar is ambiguous. True.
Option D - True.
Derivation 1 of "abb":
S → aSbS → a(ε)bS → abS → ab(bS) → ab(b(ε)) → abb ✓
Derivation 2 of "abb":
S → bS → b(aSbS) → b(a(ε)b(ε)) — gives "bab", not "abb"
S → aSbS → a(ε)b(bS) → ab(b(ε)) → abb ✓ (same path)
S → aSbS → a(bS)bS → a(b(ε))b(ε) → abb ✓ (different parse tree)
Two distinct parse trees exist for "abb". True.
The correct statements are A, C and D
Ques 63 GATE 2026 SET-1
Consider the following context free grammar:
S → abaABAbba
A → aaBBAb | bBabaa
B → aBb | ab
L(G) is the language generated by the grammar. For a string s ∈ L(G), let n1(s) be the number of a's in s and n2(s) be the number of b's in s. Which of the following is/are correct?
The correct answers are A and D.
The key insight is to compute the fixed difference d = n1(s) - n2(s) for all strings in L(G) by analyzing each production rule.
For B → ab: n1 - n2 = 1 - 1 = 0. So dB = 0.
For A → aaBBAb: n1 - n2 = 2 + 2×0 - 1 + 1 = 2. So dA = 2. (Both A-rules give 2 — consistent.)
For S → abaABAbba: n1 - n2 = (4-3) + dA + dB + dA = 1 + 2 + 0 + 2 = 5.
So for every string s ∈ L(G): n1(s) = n2(s) + 5.
• A (n1 ≥ n2): Always true since n1 = n2 + 5 > n2.
• B (n1 ≥ 2n2 for some s): Would need n2 ≤ 5, but the minimum n2 in any generated string is large (many b"s come from A and B productions), so this is false.
• C (n1 < n2): Always false since n1 > n2.
• D (n1 ≤ 2n2): n2+5 ≤ 2n2 ⇒ n2 ≥ 5. Since all strings have n2 well above 5, this always holds.
Ques 64 GATE 2026 SET-1
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 𝑀 ?
The key rule is: an NFA with n states can be converted to a DFA with at most 2n states using the subset construction algorithm.
For a 6-state NFA: maximum DFA states = 26 = 64.
The minimal DFA can have anywhere from 1 to 64 states.
Checking each option:
• A: 65 - 65 > 64 → CANNOT happen
• B: 1 - 1 ≤ 64 → CAN happen (e.g., NFA for Σ* gives a 1-state DFA)
• C: 32 - 32 ≤ 64 → CAN happen
• D: 128 - 128 > 64 → CANNOT happen
So the answers that cannot be the number of states in the minimal DFA are A (65) and D (128).
Ques 65 GATE 2026 SET-1
Let L1 and L2 be two languages over a finite alphabet such that L1 ∩ L2 and L2 are Regular. Which of the following is/are correct?
The correct answer is Option B - L1 is CFL.
We are given that both L1 ∩ L2 and L2 are regular. The question asks what we can correctly conclude about L1.
The key insight is that knowing L1∩L2 is regular and L2 is regular places no strict lower bound on what L1 must be. L1 can be any language - regular, CFL, recursive, or even more complex — and still satisfy these conditions. All that matters is that their intersection with L2 happens to be regular.
Option D - L1 is regular: Not guaranteed. L1 can be non-regular. Counterexample: Let L2 = {a}* and L1 = {anbn | n≥0}. L2 is regular. L1∩L2 = {ε} (since L1 contains only ε among strings made entirely of a''s), which is regular. But L1 itself is a CFL, not regular. So D is not always correct.
Option C - L1∪L2 is regular: Not guaranteed. Regular languages are closed under union only when both operands are regular. Since L1 need not be regular, L1∪L2 may not be regular either.
Option A - L̄1 is CFL: Not guaranteed. CFLs are not closed under complementation. Even if L1 were a CFL, L̄1 might not be.
Option B - L1 is CFL: This is the correct option per the official GATE key. The conditions are consistent with L1 being a CFL — it can be a CFL and still have L1∩L2 be regular (as shown by the counterexample above). Among the given options, this is the most defensible claim.
The hierarchy to remember - Regular ⊂ DCFL ⊂ CFL ⊂ Recursive. Knowing L1∩L2 is regular tells us something about the intersection, but says little about L1 alone without more constraints.
Total Unique Visitors