ClassScribeVol. 1August 2026

Q·Magazine

GATE CS — Subject-wise Special

Ten hand-picked questions from every core GATE Computer Science subject — with full solutions.

100Questions
10Subjects
GATE CSFocus

In this edition

01
GATE CS · Subject

Engineering Mathematics

Linear algebra, calculus, probability and discrete mathematics.

Q1.
Linear AlgebraMediumNumerical
Find the eigenvalues of the matrix [4123]\begin{bmatrix} 4 & 1 \\ 2 & 3 \end{bmatrix}.
Reveal solution
Answer
2 and 5
Solution

Characteristic equation: λ27λ+10=0(λ2)(λ5)=0\lambda^2 - 7\lambda + 10 = 0 \Rightarrow (\lambda-2)(\lambda-5)=0. Eigenvalues are 2 and 5.

Q2.
Linear AlgebraMediumNumerical
If a 3×33\times3 matrix AA has eigenvalues 1,2,31, 2, 3, what is det(A)\det(A)?
Reveal solution
Answer
6
Solution

The determinant equals the product of the eigenvalues: 1×2×3=61\times2\times3 = 6.

Q3.
CalculusMediumNumerical
Evaluate 01x2dx\displaystyle\int_0^1 x^2\,dx.
Reveal solution
Answer
1/3
Solution

01x2dx=[x33]01=13\int_0^1 x^2\,dx = \left[\tfrac{x^3}{3}\right]_0^1 = \tfrac13.

Q4.
CalculusMediumNumerical
Find limx0sin5xx\displaystyle\lim_{x\to 0} \frac{\sin 5x}{x}.
Reveal solution
Answer
5
Solution

limx0sin5xx=5limx0sin5x5x=5×1=5\lim_{x\to0}\tfrac{\sin 5x}{x} = 5\lim_{x\to0}\tfrac{\sin 5x}{5x} = 5\times1 = 5.

Q5.
ProbabilityMediumNumerical
For events with P(A)=0.5P(A)=0.5, P(B)=0.4P(B)=0.4, P(AB)=0.2P(A\cap B)=0.2, find P(AB)P(A\cup B).
Reveal solution
Answer
0.7
Solution

P(AB)=P(A)+P(B)P(AB)=0.5+0.40.2=0.7P(A\cup B) = P(A)+P(B)-P(A\cap B) = 0.5+0.4-0.2 = 0.7.

Q6.
ProbabilityMediumNumerical
What is the expected value of a single roll of a fair six-sided die?
Reveal solution
Answer
3.5
Solution

E[X]=1+2+3+4+5+66=216=3.5E[X] = \tfrac{1+2+3+4+5+6}{6} = \tfrac{21}{6} = 3.5.

Q7.
Discrete Maths · SetsMediumNumerical
How many subsets does a set with 5 elements have?
Reveal solution
Answer
32
Solution

A set of nn elements has 2n2^n subsets: 25=322^5 = 32.

Q8.
Discrete Maths · FunctionsHardNumerical
How many ONTO functions exist from a 4-element set to a 3-element set?
Reveal solution
Answer
36
Solution

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

Q9.
Graph TheoryMediumNumerical
How many edges does the complete graph K5K_5 have?
Reveal solution
Answer
10
Solution

KnK_n has (n2)\binom{n}{2} edges: (52)=10\binom52 = 10.

Q10.
CombinatoricsMediumNumerical
In how many ways can 3 students be selected from a group of 8?
Reveal solution
Answer
56
Solution

(83)=8×7×63!=56\binom{8}{3} = \dfrac{8\times7\times6}{3!} = 56.

02
GATE CS · Subject

Digital Logic

Number systems, Boolean algebra, and combinational & sequential circuits.

Q1.
Number SystemsMediumNumerical
What is the decimal value of the binary number 101121011_2?
Reveal solution
Answer
11
Solution

18+04+12+11=111\cdot8 + 0\cdot4 + 1\cdot2 + 1\cdot1 = 11.

Q2.
Number SystemsHardMCQ
What is the 4-bit 2’s complement representation of 6-6?
  • A) 1001
  • B) 1010
  • C) 0110
  • D) 1110
Reveal solution
Answer
B
Solution

+6=0110+6 = 0110; invert to 10011001, add 1 → 10101010.

Q3.
Boolean AlgebraMediumMCQ
Simplify the Boolean expression A+ABA + A'B.
  • A) AA
  • B) BB
  • C) A+BA + B
  • D) ABAB
Reveal solution
Answer
C
Solution

By the absorption/redundancy law, A+AB=A+BA + A'B = A + B.

Q4.
Combinational CircuitsMediumNumerical
How many select lines are required for an 8:18:1 multiplexer?
Reveal solution
Answer
3
Solution

A 2n:12^n : 1 MUX needs nn select lines; 8=238 = 2^3, so 3.

Q5.
Logic GatesMediumNumerical
What is the output of an XOR gate when both inputs are 1?
Reveal solution
Answer
0
Solution

XOR outputs 1 only when inputs differ; 11=01\oplus1 = 0.

Q6.
Combinational CircuitsHardMCQ
The SUM output of a full adder with inputs AA, BB and carry-in CinC_{in} is:
  • A) ABCinA \cdot B \cdot C_{in}
  • B) ABCinA \oplus B \oplus C_{in}
  • C) A+B+CinA + B + C_{in}
  • D) ABA \oplus B
Reveal solution
Answer
B
Solution

Full-adder SUM =ABCin= A \oplus B \oplus C_{in}; carry =AB+Cin(AB)= AB + C_{in}(A\oplus B).

Q7.
Sequential CircuitsMediumNumerical
How many flip-flops are required to build a mod-16 counter?
Reveal solution
Answer
4
Solution

A mod-NN counter needs log2N\lceil \log_2 N \rceil flip-flops; log216=4\log_2 16 = 4.

Q8.
Number SystemsMediumMCQ
What is the range of an 8-bit signed number in 2’s complement?
  • A) 0 to 255
  • B) −127 to +127
  • C) −128 to +127
  • D) −128 to +128
Reveal solution
Answer
C
Solution

For nn-bit 2’s complement the range is 2n1-2^{n-1} to 2n112^{n-1}-1: 128-128 to +127+127.

Q9.
Number SystemsMediumMCQ
The hexadecimal equivalent of the binary number 11011010211011010_2 is:
  • A) DA
  • B) AD
  • C) D8
  • D) BA
Reveal solution
Answer
A
Solution

Group in nibbles: 1101=D1101 = D, 1010=A1010 = ADADA.

Q10.
Logic GatesMediumNumerical
How many 2-input NAND gates are needed to implement a NOT gate?
Reveal solution
Answer
1
Solution

Tie both inputs of a NAND together: AA=A\overline{A\cdot A} = \overline{A}.

03
GATE CS · Subject

Computer Organization & Architecture

Addressing, datapath, pipelining and the memory hierarchy.

Q1.
Cache MemoryHardNumerical
A 32-bit byte-addressable machine has an 8 KB direct-mapped cache with a 16-byte block. How many bits are in the TAG field?
Reveal solution
Answer
19
Solution

Blocks =8KB/16=5129= 8\text{KB}/16 = 512 \Rightarrow 9 index bits; offset =log216=4= \log_2 16 = 4; tag =3294=19= 32 - 9 - 4 = 19.

Q2.
Memory HierarchyHardNumerical
Cache hit ratio is 0.9 with 10 ns access; on a miss, main memory adds 100 ns. What is the average memory access time (in ns)?
Reveal solution
Answer
20
Solution

AMAT =10+(10.9)×100=10+10=20= 10 + (1-0.9)\times100 = 10 + 10 = 20 ns (hit time + miss rate × miss penalty).

Q3.
PipeliningMediumNumerical
A processor has ideal CPI =1=1. Branches are 20% of instructions and each costs a 2-cycle penalty. What is the effective CPI?
Reveal solution
Answer
1.4
Solution

Effective CPI =1+0.2×2=1.4= 1 + 0.2\times2 = 1.4.

Q4.
AddressingMediumNumerical
How many address lines are needed to address a 1K × 8 memory?
Reveal solution
Answer
10
Solution

1K=2101\text{K} = 2^{10} locations, so 10 address lines.

Q5.
PipeliningMediumMCQ
The ideal speedup of a kk-stage pipeline (large instruction count) approaches:
  • A) kk
  • B) k2k^2
  • C) logk\log k
  • D) 2k2k
Reveal solution
Answer
A
Solution

With enough instructions and no stalls, a kk-stage pipeline approaches a speedup of kk.

Q6.
Memory HierarchyMediumNumerical
A memory has 2202^{20} words. How many bits are needed to address any word?
Reveal solution
Answer
20
Solution

2202^{20} words need 20 address bits.

Q7.
ArithmeticMediumMCQ
Booth’s multiplication algorithm is most efficient for multipliers that contain:
  • A) Alternating 0s and 1s
  • B) Long runs of consecutive 1s
  • C) A single 1
  • D) All zeros
Reveal solution
Answer
B
Solution

Booth’s encoding replaces a run of 1s with one subtract and one add, so long runs of 1s minimize operations.

Q8.
Cache MemoryMediumMCQ
In a write-back cache, a modified block is written to main memory:
  • A) On every write
  • B) When the block is evicted
  • C) Never
  • D) Only on a cache hit
Reveal solution
Answer
B
Solution

Write-back defers memory writes until the dirty block is replaced (evicted), reducing memory traffic.

Q9.
Addressing ModesMediumMCQ
In which addressing mode does the instruction contain the operand itself?
  • A) Register
  • B) Immediate
  • C) Indirect
  • D) Indexed
Reveal solution
Answer
B
Solution

Immediate addressing embeds the operand value directly in the instruction.

Q10.
I/OMediumMCQ
DMA (Direct Memory Access) improves performance mainly by:
  • A) Increasing clock speed
  • B) Letting devices transfer data to/from memory without CPU involvement per word
  • C) Adding more cache
  • D) Reducing the instruction set
Reveal solution
Answer
B
Solution

DMA transfers data between I/O and memory without the CPU handling each word, freeing the CPU.

04
GATE CS · Subject

Programming & Data Structures

C programming, pointers, and core data structures.

Q1.
PointersMediumMCQ
For int a[5] = {1,2,3,4,5}; int *p = a;, what is *(p + 3) + 2?
  • A) 5
  • B) 6
  • C) 4
  • D) undefined
Reveal solution
Answer
B
Solution

p+3 points to a[3]=4, so *(p+3)=4; then 4+2=6.

Q2.
TreesMediumMCQ
The maximum number of nodes in a binary tree of height hh (root at height 0) is:
  • A) 2h2^h
  • B) 2h+112^{h+1} - 1
  • C) 2h+12h + 1
  • D) h2h^2
Reveal solution
Answer
B
Solution

A full binary tree of height hh has 2h+112^{h+1}-1 nodes.

Q3.
Balanced TreesHardNumerical
What is the minimum number of nodes in an AVL tree of height 5 (height = edges on the longest path)?
Reveal solution
Answer
20
Solution

N(h)=N(h1)+N(h2)+1N(h)=N(h-1)+N(h-2)+1, N(0)=1,N(1)=2N(5)=20N(0)=1,N(1)=2 \Rightarrow N(5)=20.

Q4.
TreesHardNumerical
How many distinct binary trees can be formed with 3 unlabeled nodes?
Reveal solution
Answer
5
Solution

This is the Catalan number C3=14(63)=5C_3 = \dfrac{1}{4}\binom{6}{3} = 5.

Q5.
StacksMediumMCQ
Which data structure is used by the system to manage function calls and returns?
  • A) Queue
  • B) Stack
  • C) Heap
  • D) Graph
Reveal solution
Answer
B
Solution

The call stack stores activation records in LIFO order for function calls/returns.

Q6.
BSTMediumMCQ
An in-order traversal of a Binary Search Tree visits the keys in:
  • A) Random order
  • B) Descending order
  • C) Ascending (sorted) order
  • D) Level order
Reveal solution
Answer
C
Solution

In-order traversal of a BST yields keys in ascending sorted order.

Q7.
QueuesMediumMCQ
A circular queue is preferred over a linear array queue mainly because it:
  • A) Allows duplicate elements
  • B) Reuses vacated front space, avoiding false overflow
  • C) Is always sorted
  • D) Uses less memory per element
Reveal solution
Answer
B
Solution

A circular queue wraps around to reuse freed slots at the front, preventing false "queue full" states.

Q8.
HashingMediumMCQ
In open addressing with linear probing, a collision is resolved by:
  • A) Chaining a linked list
  • B) Probing the next sequential slot
  • C) Rehashing the whole table
  • D) Ignoring the key
Reveal solution
Answer
B
Solution

Linear probing checks the next consecutive slots until an empty one is found.

Q9.
Linked ListsMediumMCQ
Finding the kk-th element from the end of a singly linked list in one pass is best done using:
  • A) Recursion only
  • B) Two pointers spaced kk apart
  • C) A stack of all nodes
  • D) Sorting the list
Reveal solution
Answer
B
Solution

Advance one pointer kk nodes, then move both together; when the lead hits the end, the trailing pointer is at the kk-th from end.

Q10.
HeapsMediumMCQ
In a min-heap stored as an array (1-indexed), the parent of the node at index ii is at index:
  • A) 2i2i
  • B) 2i+12i+1
  • C) i/2\lfloor i/2 \rfloor
  • D) i1i-1
Reveal solution
Answer
C
Solution

In a 1-indexed binary heap, parent(i)=i/2(i) = \lfloor i/2 \rfloor, children are 2i2i and 2i+12i+1.

05
GATE CS · Subject

Algorithms

Complexity, divide & conquer, greedy, DP and graph algorithms.

Q1.
RecurrencesMediumMCQ
The recurrence T(n)=2T(n/2)+nT(n) = 2T(n/2) + n solves to:
  • A) Θ(n)\Theta(n)
  • B) Θ(nlogn)\Theta(n\log n)
  • C) Θ(n2)\Theta(n^2)
  • D) Θ(logn)\Theta(\log n)
Reveal solution
Answer
B
Solution

By the Master Theorem (case 2), a=bda=b^{\,d} with d=1d=1 gives Θ(nlogn)\Theta(n\log n) — this is merge sort.

Q2.
RecurrencesHardMCQ
The recurrence T(n)=2T(n/2)+nlognT(n) = 2T(n/2) + \dfrac{n}{\log n} solves to:
  • A) Θ(nlogn)\Theta(n\log n)
  • B) Θ(n)\Theta(n)
  • C) Θ(nloglogn)\Theta(n\log\log n)
  • D) Θ(n2)\Theta(n^2)
Reveal solution
Answer
C
Solution

The Master Theorem fails; summing levels gives n1/k=Θ(nloglogn)n\sum 1/k = \Theta(n\log\log n).

Q3.
SortingMediumMCQ
The worst-case time complexity of Quicksort is:
  • A) O(nlogn)O(n\log n)
  • B) O(n)O(n)
  • C) O(n2)O(n^2)
  • D) O(logn)O(\log n)
Reveal solution
Answer
C
Solution

A poor pivot (e.g. sorted input, last-element pivot) gives O(n2)O(n^2); average is O(nlogn)O(n\log n).

Q4.
SearchingMediumNumerical
What is the maximum number of comparisons binary search makes on a sorted array of 1000 elements?
Reveal solution
Answer
10
Solution

log21000=10\lceil \log_2 1000 \rceil = 10.

Q5.
SelectionMediumNumerical
What is the minimum number of comparisons to find both the maximum and minimum of 100 distinct numbers?
Reveal solution
Answer
148
Solution

3n/22=1502=148\lceil 3n/2 \rceil - 2 = 150 - 2 = 148 (pair up, then compare winners and losers).

Q6.
GreedyMediumMCQ
Which algorithm finds a Minimum Spanning Tree using a greedy edge-selection with a disjoint-set structure?
  • A) Dijkstra
  • B) Kruskal
  • C) Bellman–Ford
  • D) Floyd–Warshall
Reveal solution
Answer
B
Solution

Kruskal’s algorithm greedily adds the lightest edge that doesn’t form a cycle, using union–find.

Q7.
Shortest PathsMediumMCQ
Which statement about Dijkstra’s algorithm is TRUE?
  • A) It works with negative edge weights
  • B) It may give wrong results if any edge weight is negative
  • C) It requires an acyclic graph
  • D) It finds the MST
Reveal solution
Answer
B
Solution

Dijkstra finalizes vertices greedily; a later negative edge can invalidate a finalized distance. Use Bellman–Ford for negatives.

Q8.
Dynamic ProgrammingMediumMCQ
The 0/1 Knapsack DP runs in O(nW)O(nW) time. This is called:
  • A) Polynomial time
  • B) Pseudo-polynomial time
  • C) Logarithmic time
  • D) Constant time
Reveal solution
Answer
B
Solution

WW is a numeric value (not input size), so O(nW)O(nW) is pseudo-polynomial — exponential in the bits of WW.

Q9.
Graph AlgorithmsMediumMCQ
Which traversal is used to find the shortest path (in edges) from a source in an unweighted graph?
  • A) DFS
  • B) BFS
  • C) Topological sort
  • D) Prim’s
Reveal solution
Answer
B
Solution

BFS explores by levels, giving the minimum number of edges from the source.

Q10.
ComplexityHardMCQ
If a problem is NP-complete, then:
  • A) It cannot be solved at all
  • B) It is in NP and every NP problem reduces to it in polynomial time
  • C) It is solvable in polynomial time
  • D) It has no verifier
Reveal solution
Answer
B
Solution

NP-complete = in NP and NP-hard (every NP problem reduces to it). A poly-time solution would imply P = NP.

06
GATE CS · Subject

Theory of Computation

Automata, formal languages, decidability and the Chomsky hierarchy.

Q1.
Finite AutomataHardNumerical
What is the minimum number of states in a DFA accepting all binary strings (MSB first) whose value is divisible by 5?
Reveal solution
Answer
5
Solution

Track remainder mod 5; on bit bb, r(2r+b)mod5r \to (2r+b)\bmod 5. Five distinguishable remainders → 5 states.

Q2.
Regular LanguagesMediumMCQ
Which language over {a,b}\{a,b\} is REGULAR?
  • A) {anbnn0}\{a^n b^n \mid n\ge0\}
  • B) {www{a,b}}\{ww \mid w\in\{a,b\}^*\}
  • C) {anbmn,m0}\{a^n b^m \mid n,m\ge0\}
  • D) {anbncn}\{a^n b^n c^n\}
Reveal solution
Answer
C
Solution

aba^*b^* needs no counting; the others require matching unbounded counts, which FAs cannot do.

Q3.
Finite AutomataMediumNumerical
How many states does the minimal DFA accepting all strings over {a,b}\{a,b\} that end in "ab" have?
Reveal solution
Answer
3
Solution

States track progress: start → seen "a" → seen "ab" (accepting); 3 states suffice.

Q4.
NFA vs DFAHardMCQ
Converting an NFA with nn states to an equivalent DFA can require, in the worst case:
  • A) nn states
  • B) n2n^2 states
  • C) 2n2^n states
  • D) n!n! states
Reveal solution
Answer
C
Solution

Subset construction can produce up to 2n2^n DFA states (one per subset of NFA states).

Q5.
Pumping LemmaMediumMCQ
The pumping lemma for regular languages is primarily used to prove that a language is:
  • A) Regular
  • B) Context-free
  • C) NOT regular
  • D) Decidable
Reveal solution
Answer
C
Solution

It gives a necessary property of regular languages; a violation proves a language is not regular.

Q6.
Context-Free LanguagesMediumMCQ
The language {anbnn0}\{a^n b^n \mid n \ge 0\} is:
  • A) Regular
  • B) Context-free but not regular
  • C) Not context-free
  • D) Undecidable
Reveal solution
Answer
B
Solution

A PDA can match aas and bbs using its stack, but no DFA can — so it is CFL but not regular.

Q7.
Closure PropertiesMediumMCQ
Regular languages are closed under which of these operations?
  • A) Union only
  • B) Intersection only
  • C) Union, intersection and complement
  • D) None
Reveal solution
Answer
C
Solution

Regular languages are closed under union, intersection, complement, concatenation and Kleene star.

Q8.
DecidabilityHardMCQ
The Halting Problem (does TM MM halt on input ww?) is:
  • A) Decidable
  • B) Undecidable but recognizable
  • C) Neither recognizable nor co-recognizable
  • D) Regular
Reveal solution
Answer
B
Solution

The Halting Problem is undecidable, but it is Turing-recognizable (semi-decidable) — a TM can accept when MM halts.

Q9.
Chomsky HierarchyMediumMCQ
Which machine model recognizes exactly the context-free languages?
  • A) Finite automaton
  • B) Pushdown automaton
  • C) Linear bounded automaton
  • D) Turing machine
Reveal solution
Answer
B
Solution

Non-deterministic pushdown automata recognize exactly the context-free languages.

Q10.
Regular ExpressionsMediumMCQ
The regular expression (aa)(aa)^* denotes all strings of aas of:
  • A) Odd length
  • B) Even length (including empty)
  • C) Length ≥ 2
  • D) Length exactly 2
Reveal solution
Answer
B
Solution

(aa)(aa)^* matches ε,aa,aaaa,\varepsilon, aa, aaaa, \dots — strings of aa with even length.

07
GATE CS · Subject

Compiler Design

Lexing, parsing, syntax-directed translation and code generation.

Q1.
PhasesMediumMCQ
Which is the correct order of the first three phases of a compiler?
  • A) Syntax → Lexical → Semantic
  • B) Lexical → Syntax → Semantic
  • C) Semantic → Syntax → Lexical
  • D) Lexical → Semantic → Syntax
Reveal solution
Answer
B
Solution

A compiler proceeds lexical analysis → syntax analysis (parsing) → semantic analysis.

Q2.
Lexical AnalysisMediumMCQ
The output of the lexical analyzer is a stream of:
  • A) Parse trees
  • B) Tokens
  • C) Three-address code
  • D) Machine code
Reveal solution
Answer
B
Solution

The lexer groups characters into tokens (identifiers, keywords, operators, literals).

Q3.
ParsingMediumMCQ
LL(1) parsers are:
  • A) Bottom-up
  • B) Top-down, predictive
  • C) Only for regular grammars
  • D) Non-deterministic
Reveal solution
Answer
B
Solution

LL(1) is top-down predictive parsing using 1 lookahead token and FIRST/FOLLOW sets.

Q4.
ParsingMediumMCQ
Which parser is the most powerful among the LR family for practical grammars?
  • A) LR(0)
  • B) SLR(1)
  • C) Canonical LR(1)
  • D) LL(1)
Reveal solution
Answer
C
Solution

Canonical LR(1) handles the largest class of grammars; LALR(1) is a compact, slightly weaker variant.

Q5.
GrammarsHardMCQ
Left recursion in a grammar is a problem specifically for:
  • A) Bottom-up parsers
  • B) Top-down (recursive-descent/LL) parsers
  • C) Lexical analysis
  • D) Code generation
Reveal solution
Answer
B
Solution

Left recursion causes infinite recursion in top-down parsers, so it must be eliminated for LL parsing.

Q6.
FIRST/FOLLOWHardMCQ
FIRST and FOLLOW sets are primarily used to construct:
  • A) The symbol table
  • B) Predictive/LL(1) parsing tables
  • C) The lexical DFA
  • D) The activation record
Reveal solution
Answer
B
Solution

FIRST/FOLLOW sets drive entries of the LL(1) predictive parsing table.

Q7.
Intermediate CodeMediumMCQ
Three-address code is a form of:
  • A) Target machine code
  • B) Intermediate representation
  • C) Token stream
  • D) Regular expression
Reveal solution
Answer
B
Solution

Three-address code (e.g. t1 = a + b) is a common intermediate representation between the front and back ends.

Q8.
Symbol TableMediumMCQ
The symbol table in a compiler stores:
  • A) Machine registers only
  • B) Identifiers and their attributes (type, scope, etc.)
  • C) The final executable
  • D) Only keywords
Reveal solution
Answer
B
Solution

The symbol table records identifiers with attributes such as type, scope and memory location.

Q9.
SDTMediumMCQ
Syntax-Directed Translation attaches ______ to grammar productions.
  • A) Tokens
  • B) Semantic rules/actions
  • C) Registers
  • D) Interrupts
Reveal solution
Answer
B
Solution

SDT associates semantic rules/actions (using synthesized/inherited attributes) with productions.

Q10.
Code GenerationHardMCQ
Register allocation is commonly modeled as which classic problem?
  • A) Sorting
  • B) Graph coloring
  • C) Shortest path
  • D) Matrix multiplication
Reveal solution
Answer
B
Solution

The interference graph is colored with kk colors (kk = registers); adjacent live variables get different registers.

08
GATE CS · Subject

Operating Systems

Scheduling, synchronization, deadlock and memory management.

Q1.
SchedulingMediumNumerical
Four processes arrive at time 0 with burst times 6, 8, 7, 3. Under non-preemptive SJF, what is the average waiting time?
Reveal solution
Answer
7
Solution

Order 3,6,7,8; waiting times 0,3,9,16; average =28/4=7=28/4 = 7.

Q2.
Page ReplacementMediumMCQ
Belady’s anomaly (more frames → more faults) can occur under which policy?
  • A) LRU
  • B) Optimal
  • C) FIFO
  • D) Any stack algorithm
Reveal solution
Answer
C
Solution

FIFO is not a stack algorithm, so adding frames can increase faults. LRU and OPT are immune.

Q3.
DeadlockMediumMCQ
Which is NOT one of the four necessary conditions for deadlock?
  • A) Mutual exclusion
  • B) Hold and wait
  • C) Preemption
  • D) Circular wait
Reveal solution
Answer
C
Solution

The four conditions are mutual exclusion, hold-and-wait, NO preemption, and circular wait. "Preemption" (allowing it) actually prevents deadlock.

Q4.
SynchronizationHardMCQ
A counting semaphore is initialized to 3. After 5 P (wait) and 3 V (signal) operations complete successfully, how many processes are blocked on it?
  • A) 0
  • B) 1
  • C) 2
  • D) 3
Reveal solution
Answer
B
Solution

Available permits over time: init 3 + 3 signals = 6 grants possible; 5 P succeed immediately/eventually, but net demand 5 vs supply 3+? Value =35+3=1= 3 - 5 + 3 = 1 ⇒ one more P than available, so 1 process is blocked.

Q5.
SchedulingMediumMCQ
Which scheduling algorithm can cause starvation of long processes?
  • A) FCFS
  • B) Round Robin
  • C) Shortest Job First
  • D) None
Reveal solution
Answer
C
Solution

SJF/priority scheduling can starve long (low-priority) jobs if short jobs keep arriving.

Q6.
Memory ManagementHardNumerical
A system uses 32-bit virtual addresses with a 4 KB page size. How many bits are used for the page offset?
Reveal solution
Answer
12
Solution

4KB=2124\text{KB} = 2^{12} bytes per page, so 12 offset bits (the remaining 20 bits are the page number).

Q7.
ConcurrencyMediumMCQ
The producer–consumer problem is typically solved using:
  • A) One mutex only
  • B) Two counting semaphores (empty, full) plus a mutex
  • C) Busy waiting only
  • D) Disabling interrupts forever
Reveal solution
Answer
B
Solution

Semaphores "empty" and "full" track buffer slots/items, and a mutex protects the shared buffer.

Q8.
DeadlockMediumMCQ
The Banker’s algorithm is used for deadlock:
  • A) Detection
  • B) Recovery
  • C) Avoidance
  • D) Prevention
Reveal solution
Answer
C
Solution

The Banker’s algorithm grants a request only if the resulting state is "safe" — it avoids deadlock.

Q9.
Virtual MemoryMediumMCQ
Thrashing occurs when:
  • A) The CPU is idle
  • B) A process spends more time paging than executing
  • C) The disk is empty
  • D) Too many CPUs are used
Reveal solution
Answer
B
Solution

Thrashing is high paging activity with low CPU utilization, caused by too little memory per active process.

Q10.
SchedulingMediumMCQ
In Round Robin scheduling, a very large time quantum makes it behave like:
  • A) SJF
  • B) FCFS
  • C) Priority scheduling
  • D) Multilevel queue
Reveal solution
Answer
B
Solution

If the quantum exceeds every burst, each process runs to completion in arrival order — i.e. FCFS.

09
GATE CS · Subject

Databases

Relational model, SQL, normalization, transactions and indexing.

Q1.
KeysHardNumerical
Relation R(A,B,C,D)R(A,B,C,D) has FDs {AB,BC,CD,DA}\{A\to B, B\to C, C\to D, D\to A\}. How many superkeys does RR have?
Reveal solution
Answer
15
Solution

The FD cycle makes every single attribute a candidate key, so every non-empty subset is a superkey: 241=152^4-1 = 15.

Q2.
NormalizationMediumMCQ
A relation is in BCNF if, for every non-trivial FD XYX\to Y:
  • A) YY is prime
  • B) XX is a superkey
  • C) XX is prime
  • D) YY is a superkey
Reveal solution
Answer
B
Solution

BCNF requires the left side of every non-trivial FD to be a superkey.

Q3.
TransactionsMediumMCQ
A schedule is conflict-serializable if and only if its precedence graph:
  • A) Is connected
  • B) Is acyclic
  • C) Has no isolated node
  • D) Is bipartite
Reveal solution
Answer
B
Solution

Conflict-serializability holds exactly when the precedence (serialization) graph has no cycle.

Q4.
ACIDMediumMCQ
The "D" in ACID properties stands for:
  • A) Distribution
  • B) Durability
  • C) Determinism
  • D) Decomposition
Reveal solution
Answer
B
Solution

ACID = Atomicity, Consistency, Isolation, Durability; committed changes survive failures.

Q5.
SQLMediumMCQ
Which SQL clause is used to filter groups produced by GROUP BY?
  • A) WHERE
  • B) HAVING
  • C) ORDER BY
  • D) DISTINCT
Reveal solution
Answer
B
Solution

WHERE filters rows before grouping; HAVING filters after aggregation on grouped results.

Q6.
Relational AlgebraMediumMCQ
A natural join between two relations combines tuples that:
  • A) Have any matching value
  • B) Agree on all common attributes
  • C) Are from the same table
  • D) Have equal cardinality
Reveal solution
Answer
B
Solution

Natural join equates tuples that match on all commonly-named attributes and drops the duplicate columns.

Q7.
IndexingMediumMCQ
In a database, a B+ tree stores actual data records:
  • A) In all nodes
  • B) Only in leaf nodes
  • C) Only in the root
  • D) In internal nodes only
Reveal solution
Answer
B
Solution

In a B+ tree, internal nodes hold only keys for routing; all record pointers/data live in the linked leaves.

Q8.
ConcurrencyHardMCQ
Two-phase locking (2PL) guarantees:
  • A) No deadlocks
  • B) Conflict-serializability
  • C) Recoverability always
  • D) No blocking
Reveal solution
Answer
B
Solution

2PL (a growing phase then a shrinking phase) guarantees conflict-serializable schedules, though deadlocks can still occur.

Q9.
Functional DependencyHardMCQ
For R(A,B,C)R(A,B,C) with ABA\to B and BCB\to C, the attribute closure A+A^+ is:
  • A) {A}\{A\}
  • B) {A,B}\{A,B\}
  • C) {A,B,C}\{A,B,C\}
  • D) {B,C}\{B,C\}
Reveal solution
Answer
C
Solution

ABA\to B and BCB\to C give ACA\to C by transitivity, so A+={A,B,C}A^+ = \{A,B,C\}AA is a key.

Q10.
NormalizationMediumMCQ
A relation is in 1NF but not 2NF when:
  • A) It has a multivalued dependency
  • B) A non-prime attribute is partially dependent on a candidate key
  • C) It has transitive dependencies
  • D) All attributes are atomic
Reveal solution
Answer
B
Solution

2NF violation = a non-prime attribute depends on part of a composite candidate key (partial dependency).

10
GATE CS · Subject

Computer Networks

Layering, addressing, routing and transport protocols.

Q1.
IP AddressingMediumNumerical
How many usable host addresses are in an IPv4 subnet with prefix /26/26?
Reveal solution
Answer
62
Solution

Host bits =3226=626=64= 32-26 = 6 \Rightarrow 2^6 = 64; minus network and broadcast → 62.

Q2.
IP AddressingMediumMCQ
What is the subnet mask for a /26/26 network?
  • A) 255.255.255.0
  • B) 255.255.255.192
  • C) 255.255.255.224
  • D) 255.255.255.128
Reveal solution
Answer
B
Solution

/26/26 sets 26 leading 1-bits: 255.255.255.11000000 = 255.255.255.192.

Q3.
IP AddressingMediumNumerical
How many /26/26 subnets can be carved out of a single /24/24 network?
Reveal solution
Answer
4
Solution

22624=22=42^{26-24} = 2^2 = 4 subnets.

Q4.
OSI ModelMediumNumerical
How many layers are there in the OSI reference model?
Reveal solution
Answer
7
Solution

Physical, Data Link, Network, Transport, Session, Presentation, Application — 7 layers.

Q5.
Transport LayerMediumMCQ
Which is TRUE of UDP compared to TCP?
  • A) UDP is connection-oriented
  • B) UDP guarantees in-order delivery
  • C) UDP is connectionless and has lower overhead
  • D) UDP has flow control
Reveal solution
Answer
C
Solution

UDP is connectionless, unreliable and lightweight — no handshake, ordering, or flow control, so lower overhead.

Q6.
Flow ControlHardNumerical
A Stop-and-Wait link has one-way propagation delay 20 ms and transmission time 1 ms per frame (ignore ACK time). What is the link efficiency (2 decimals)?
Reveal solution
Answer
0.02
Solution

Efficiency =TtTt+2Tp=11+40=1410.02= \dfrac{T_t}{T_t + 2T_p} = \dfrac{1}{1+40} = \dfrac{1}{41} \approx 0.02.

Q7.
Data Link LayerMediumMCQ
CSMA/CD is the access method used historically by:
  • A) Token Ring
  • B) Ethernet (shared medium)
  • C) ATM
  • D) FDDI
Reveal solution
Answer
B
Solution

Ethernet used CSMA/CD — carrier sense, and collision detection with back-off — on a shared medium.

Q8.
Error DetectionHardMCQ
To detect up to dd single-bit errors, the minimum Hamming distance of a code must be at least:
  • A) dd
  • B) d+1d+1
  • C) 2d2d
  • D) 2d+12d+1
Reveal solution
Answer
B
Solution

A minimum Hamming distance of d+1d+1 detects up to dd bit errors; 2d+12d+1 is needed to correct dd errors.

Q9.
Application LayerMediumMCQ
The default port numbers for HTTP and HTTPS respectively are:
  • A) 21 and 22
  • B) 80 and 443
  • C) 25 and 110
  • D) 443 and 80
Reveal solution
Answer
B
Solution

HTTP uses TCP port 80; HTTPS uses TCP port 443.

Q10.
Network LayerMediumMCQ
Which protocol resolves an IP address to a MAC address on a local network?
  • A) DNS
  • B) ARP
  • C) DHCP
  • D) ICMP
Reveal solution
Answer
B
Solution

ARP (Address Resolution Protocol) maps a known IPv4 address to its link-layer MAC address.

Want the full GATE CS grind?

Generate unlimited subject-wise mock tests with AI, or work through our free exam question banks.