GATE CS Mock Test 1 (30 Questions, Free)

A free GATE CS mock test with 30 original questions across aptitude, maths and every CS subject, in MCQ, MSQ and NAT formats with full solutions.

This mock test has 30 original GATE-style questions covering General Aptitude, Engineering Mathematics and every core CS subject, in the same mix of MCQ, MSQ and NAT that GATE uses. It is about half the length of a real paper, so give yourself 90 minutes.

How to take it: note your answers on paper first, then open each question to check. Score +1 per correct answer, and −1/3 for each wrong MCQ (as for a one-mark GATE question). Read the marking scheme for details.

General Aptitude

GATE-styleMCQ · one correct answer

[GA] Choose the word that best completes the sentence: "The committee's report was so ______ that even experts struggled to follow its argument."

Show answer and explanationAnswer: B

The second half says experts struggled to follow it, so the report was complicated: convoluted. Lucid and concise mean the opposite.

GATE-styleNAT · numerical answer

[GA] A shopkeeper marks a price 40% above cost and then gives a 25% discount. What is the profit percentage?

Show answer and explanationAnswer: 5

Selling price = 1.4 × 0.75 = 1.05 times cost: a 5% profit.

GATE-styleMCQ · one correct answer

[GA] P, Q, R and S sit in a row. Q is not at either end. R is immediately to the right of P. S is at the right end. Who is at the left end?

Show answer and explanationAnswer: A

S is at position 4, so Q is at 2 or 3. If Q were at 2, the pair P, R would need positions 3 and 4, but 4 is taken. So Q is at 3, and P, R take positions 1 and 2: the row is P, R, Q, S, with P at the left end.

GATE-styleNAT · numerical answer

[GA] Pipe A fills a tank in 10 hours and pipe B empties it in 15 hours. If both are open, how many hours does the empty tank take to fill?

Show answer and explanationAnswer: 30

Net rate = 1/10 − 1/15 = 1/30 of the tank per hour: 30 hours.

GATE-styleNAT · numerical answer

[GA] What is the next number in the series 3, 7, 15, 31, 63, …?

Show answer and explanationAnswer: 127

Each term is twice the previous plus 1 (they are 2^n − 1): 2 × 63 + 1 = 127.

Engineering Mathematics

GATE-styleMCQ · one correct answer

[Linear algebra] The eigenvalues of the matrix [[2, 1], [1, 2]] are:

Show answer and explanationAnswer: B

Trace 4 and determinant 3, so λ² − 4λ + 3 = 0, giving λ = 1 and 3.

GATE-styleNAT · numerical answer

[Linear algebra] What is the rank of [[1, 2, 3], [2, 4, 6], [1, 1, 1]]?

Show answer and explanationAnswer: 2

Row 2 is twice row 1, and rows 1 and 3 are independent, so the rank is 2.

GATE-styleNAT · numerical answer

[Probability] Two fair dice are rolled. What is the probability that the sum is 8? (Give 3 decimal places.)

Show answer and explanationAnswer: 0.139

(2,6), (3,5), (4,4), (5,3), (6,2): 5 of 36 outcomes, 5/36 ≈ 0.139.

GATE-styleNAT · numerical answer

[Calculus] What is the limit of (1 − cos x) / x² as x → 0? (Give 1 decimal place.)

Show answer and explanationAnswer: 0.5

1 − cos x ≈ x²/2 for small x, so the limit is 1/2.

GATE-styleNAT · numerical answer

[Discrete maths] How many onto functions are there from a set of 4 elements to a set of 3 elements?

Show answer and explanationAnswer: 36

By inclusion–exclusion: 3⁴ − 3 × 2⁴ + 3 × 1⁴ = 81 − 48 + 3 = 36.

GATE-styleMSQ · one or more correct answers

[Discrete maths] Which of the following are tautologies? (Select all that apply.)

Show answer and explanationAnswer: A, B, D

p → (p ∧ q) is false when p is true and q is false. The other three are true for every assignment.

Programming, Data Structures and Algorithms

GATE-styleNAT · numerical answer

[C] What does this program print?

#include <stdio.h>
int f(int n) { return n <= 1 ? 1 : n * f(n - 2); }
int main(void) { printf("%d\n", f(7)); return 0; }
Show answer and explanationAnswer: 105

f(7) = 7 × 5 × 3 × f(1) = 105.

GATE-styleNAT · numerical answer

[DS] The keys 50, 30, 70, 20, 40, 60, 80, 35 are inserted in that order into an empty BST. What is the height of the tree? (A single node has height 0.)

Show answer and explanationAnswer: 3

The longest path is 50 → 30 → 40 → 35, which has 3 edges.

GATE-styleNAT · numerical answer

[DS] A max-heap is stored in an array (index 1 is the root). Which index holds the parent of the element at index 13?

Show answer and explanationAnswer: 6

The parent of index i is ⌊i/2⌋ = 6.

GATE-styleMCQ · one correct answer

[Algorithms] What is the time complexity of T(n) = 2T(n/2) + n log n?

Show answer and explanationAnswer: B

Each of the log n levels does about n log n work in total (shrinking slowly), which sums to Θ(n log² n).

GATE-styleNAT · numerical answer

[Algorithms] What is the minimum number of comparisons needed to find both the maximum and the minimum of 100 numbers?

Show answer and explanationAnswer: 148

Compare in pairs: ⌈3n/2⌉ − 2 = 150 − 2 = 148 for n = 100.

GATE-styleMSQ · one or more correct answers

[Algorithms] Which of the following are true about Dijkstra's algorithm? (Select all that apply.)

Show answer and explanationAnswer: A, B

Dijkstra finds shortest paths (not an MST) on directed or undirected graphs with non-negative weights.

Digital Logic and Computer Organization

GATE-styleNAT · numerical answer

[Digital logic] What is the decimal value of the 8-bit 2's complement number 11101100?

Show answer and explanationAnswer: -20

236 − 256 = −20.

GATE-styleNAT · numerical answer

[Digital logic] How many minterms does the function F(A, B, C) = A + BC have?

Show answer and explanationAnswer: 5

A = 1 gives 4 minterms; A = 0 with B = C = 1 gives one more: 5.

GATE-styleNAT · numerical answer

[COA] A cache has 64 lines of 32 bytes each and is 4-way set associative. With 32-bit addresses, how many tag bits are there?

Show answer and explanationAnswer: 23

Sets = 64/4 = 16 (4 index bits), offset = 5 bits, so tag = 32 − 4 − 5 = 23.

GATE-styleNAT · numerical answer

[COA] A non-pipelined processor takes 10 ns per instruction. A 5-stage pipeline has a 2.5 ns clock. What is the speedup for a very long program with no stalls?

Show answer and explanationAnswer: 4

In the steady state one instruction finishes per cycle: 10 / 2.5 = 4.

Operating Systems

GATE-styleNAT · numerical answer

[OS] Processes P1, P2, P3 arrive at time 0 with bursts 6, 3, 1 ms. What is the average waiting time under SJF? (Give 2 decimal places.)

Show answer and explanationAnswer: 1.67

Order P3, P2, P1: waits 0, 1 and 4. Average 5/3 ≈ 1.67 ms.

GATE-styleNAT · numerical answer

[OS] With 3 frames and FIFO replacement, how many page faults occur for the reference string 1 2 3 4 1 2 5 1 2 3 4 5?

Show answer and explanationAnswer: 9

Simulating FIFO gives 9 faults. (With 4 frames it gives 10: Belady's anomaly.)

GATE-styleNAT · numerical answer

[OS] A system has 32-bit virtual addresses, 4 KB pages and 4-byte page table entries. What is the size of a single-level page table in MB?

Show answer and explanationAnswer: 4

2^20 pages × 4 bytes = 4 MB.

Databases

GATE-styleMCQ · one correct answer

[DBMS] R(A, B, C, D) has FDs A → B, B → C, C → D. Which is the highest normal form R satisfies?

Show answer and explanationAnswer: A

The key is A. No partial dependencies (single-attribute key), so 2NF holds; B → C is transitive, so it is not 3NF.

GATE-styleNAT · numerical answer

[DBMS] Relation R has 10 tuples and S has 20. What is the maximum number of tuples in R ⋈ S (natural join) when they share no attributes?

Show answer and explanationAnswer: 200

With no common attributes, the natural join is the Cartesian product: 10 × 20 = 200.

Computer Networks and TOC / Compilers

GATE-styleNAT · numerical answer

[CN] How many /26 subnets can be made from the block 192.168.10.0/24?

Show answer and explanationAnswer: 4

Borrowing 2 bits gives 2² = 4 subnets of 64 addresses each.

GATE-styleNAT · numerical answer

[CN] A sender uses Go-Back-N with 3-bit sequence numbers. What is the maximum sender window size?

Show answer and explanationAnswer: 7

For Go-Back-N, W ≤ 2^k − 1 = 7.

GATE-styleNAT · numerical answer

[TOC] What is the minimum number of states in a DFA over {0, 1} that accepts binary numbers divisible by 3 (read most significant bit first)?

Show answer and explanationAnswer: 3

The DFA tracks the remainder mod 3 (0, 1 or 2); all three states are distinguishable.

GATE-styleMSQ · one or more correct answers

[TOC] Which of these languages are context-free but not regular? (Select all that apply.)

Show answer and explanationAnswer: A, B

aⁿbⁿ and balanced parentheses need a stack. aⁿbⁿcⁿ is not context-free; an even number of a's is regular.

Your score

Score (out of 30)What it means
24 and aboveStrong: focus on speed with full-length papers
15 – 23Good base: revise the subjects where you lost marks
Below 15Go back to the lessons of your weakest subjects, then retake this test after two weeks

Next steps: revise with the formula sheet and solve each subject's practice set.