GATE 2025 — Computer Science (CS)

General Aptitude + CS Subjects 65 Questions 100 Marks
Time Remaining: 60:00

Click any option to check your answer.

Sections: Aptitude DS & Algo CO & OS Theory
Q1. General Aptitude
The sum of ages of A and B is 45 years. 5 years from now, the ratio of their ages will be 4:5. Find the current age of A.
A. 15 years
B. 20 years
C. 25 years
D. 30 years
Correct Answer: A
Let A's age = x, B's age = 45-x. After 5 years: (x+5)/(50-x) = 4/5. 5x+25 = 200-4x. 9x = 175. x = 15.
Q2. General Aptitude
If LOGIC is coded as 15-15-7-9-3, then what is the code for MATH?
A. 1-13-20-8
B. 13-1-20-8
C. 14-1-21-9
D. 12-1-19-7
Correct Answer: C
Each letter is coded as its position + 1. L(12)+3=15, O(15)+0=15, G(7)+0=7, I(9)+0=9, C(3)+0=3. For MATH: M(13)+1=14, A(1)+0=1, T(20)+1=21, H(8)+1=9 → 14-1-21-9.
Q3. Data Structures & Algorithms
What is the time complexity of binary search on a sorted array of n elements?
A. O(n)
B. O(log n)
C. O(n²)
D. O(n log n)
Correct Answer: B
Binary search divides the search space in half each iteration, giving O(log n) time complexity.
Q4. Data Structures & Algorithms
A stack is implemented using an array. If the top pointer is at index 5, what is the current size of the stack?
A. 6
B. 5
C. 4
D. 7
Correct Answer: A
If top = 5 (0-indexed), there are 6 elements at indices 0 through 5.
Q5. Data Structures & Algorithms
Which data structure is used for implementing recursion?
A. Queue
B. Array
C. Stack
D. Linked List
Correct Answer: C
Recursion uses the call stack (LIFO) to store function call frames and return addresses.
Q6. Computer Organization & OS
Which memory has the fastest access time?
A. RAM
B. Cache
C. Hard Disk
D. SSD
Correct Answer: B
Cache memory is closest to the CPU and has the fastest access time (nanoseconds), followed by RAM, then SSD, then HDD.
Q7. Computer Organization & OS
Which scheduling algorithm is non-preemptive?
A. Round Robin
B. FCFS
C. Shortest Remaining Time First
D. Priority (Preemptive)
Correct Answer: B
First Come First Serve (FCFS) is non-preemptive — once a process gets the CPU, it runs until completion or I/O.
Q8. Computer Organization & OS
The main function of an operating system is:
A. Compiling programs
B. Providing internet access
C. Managing hardware resources
D. Running applications
Correct Answer: C
The OS manages CPU, memory, I/O devices, and provides resource allocation and protection.
Q9. Theory of Computation
A language accepted by a Finite Automaton is called:
A. Regular language
B. Context-free language
C. Context-sensitive language
D. Recursively enumerable language
Correct Answer: A
Finite automata accept exactly the class of regular languages (Type 3 in Chomsky hierarchy).
Q10. Theory of Computation
Which of the following is NOT a valid Boolean algebra property?
A. A · 0 = 0
B. A + 1 = 1
C. A · A = A
D. A + A = 0
Correct Answer: D
A + A = A (idempotent law), not 0. A + A̅ = 1 and A · A̅ = 0.
Q11. Data Structures & Algorithms
What does the following C expression evaluate to? (Assume i = 5) i++ + ++i
A. 10
B. 11
C. 12
D. Undefined
Correct Answer: C
i++ uses current value (5) then increments to 6. ++i increments to 7 then uses 7. So 5 + 7 = 12.
Q12. Computer Organization & OS
In virtual memory, which technique is used for address translation?
A. Segmentation
B. Compaction
C. Paging
D. Swapping
Correct Answer: C
Paging maps virtual addresses to physical addresses using page tables, enabling virtual memory.
Q13. General Aptitude
A train 150 m long passes a pole in 15 seconds. Find the speed of the train in km/h.
A. 12 km/h
B. 24 km/h
C. 36 km/h
D. 48 km/h
Correct Answer: C
Speed = distance/time = 150/15 = 10 m/s. In km/h: 10 × (18/5) = 36 km/h.
Q14. Theory of Computation
Which of the following problems is undecidable?
A. Checking if a DFA accepts a given string
B. Checking if a CFL is empty
C. The Halting Problem for Turing Machines
D. Checking if an NFA accepts a given string
Correct Answer: C
The Halting Problem is undecidable (proved by Alan Turing). All other options are decidable.
Q15. DS & Algorithms
The worst-case time complexity of quicksort is:
A. O(log n)
B. O(n log n)
C. O(n²)
D. O(n)
Correct Answer: C
Quicksort worst-case O(n²) when pivot is smallest/largest element (e.g., sorted array with naive pivot).
Q16. General Aptitude
If 5 men can build a wall in 12 days, how many days will 10 men take?
A. 24
B. 12
C. 6
D. 3
Correct Answer: C
M₁D₁ = M₂D₂ → 5×12 = 10×D₂ → D₂ = 6 days.
Q17. General Aptitude
Find the missing number: 2, 6, 12, 20, ?
A. 28
B. 24
C. 30
D. 36
Correct Answer: C
Pattern: 1×2=2, 2×3=6, 3×4=12, 4×5=20, 5×6=30.
Q18. DS & Algorithms
Which of the following is a linear data structure?
A. Tree
B. Queue
C. Graph
D. Binary Tree
Correct Answer: B
Queue is linear (elements in sequence). Tree and Graph are non-linear data structures.
Q19. DS & Algorithms
The height of a complete binary tree with n nodes is:
A. n
B. n/2
C. ⌊log₂n⌋
D. √n
Correct Answer: C
Height of a complete binary tree with n nodes is ⌊log₂n⌋.
Q20. DS & Algorithms
In a min-heap, the smallest element is at:
A. Root
B. Leftmost leaf
C. Rightmost leaf
D. Last node
Correct Answer: A
Min-heap property: parent ≤ children, so root is always the minimum element.
Q21. CO & OS
Which of the following is a volatile memory?
A. ROM
B. Hard disk
C. RAM
D. Flash drive
Correct Answer: C
RAM (Random Access Memory) is volatile — data is lost when power is turned off.
Q22. CO & OS
The number of bits in a nibble is:
A. 2
B. 4
C. 8
D. 16
Correct Answer: B
1 nibble = 4 bits. 1 byte = 2 nibbles = 8 bits.
Q23. CO & OS
Which of the following is NOT an operating system?
A. Windows
B. Linux
C. Python
D. macOS
Correct Answer: C
Python is a programming language, not an operating system.
Q24. CO & OS
The full form of FIFO is:
A. First In First Out
B. First In First Out
C. Fast Input Fast Output
D. First In Final Out
Correct Answer: B
FIFO = First In First Out — used in queue scheduling and page replacement.
Q25. Theory of Computation
Which language is accepted by Pushdown Automata?
A. Regular
B. Context-Free
C. Context-Sensitive
D. Recursively Enumerable
Correct Answer: B
PDA accepts exactly the class of Context-Free Languages (CFL).
Q26. Theory of Computation
If L and ¬L are both recursively enumerable, then L is:
A. Regular
B. Context-Free
C. Recursive
D. Not recursively enumerable
Correct Answer: C
If L and its complement are both RE, then L is recursive (decidable).
Q27. DS & Algorithms
Which traversal gives sorted order in a BST?
A. Preorder
B. Postorder
C. Inorder
D. Level order
Correct Answer: C
Inorder traversal of BST visits nodes in ascending order (left → root → right).
Q28. General Aptitude
Find the odd one out: 2, 4, 8, 16, 24, 32
A. 4
B. 8
C. 24
D. 32
Correct Answer: C
All others are powers of 2 (2¹, 2², 2³, 2⁴, 2⁵). 24 is not a power of 2.
Q29. CO & OS
A semaphore that is used as a binary lock is called:
A. Counting semaphore
B. Mutex
C. Spinlock
D. Monitor
Correct Answer: B
Mutex (mutual exclusion) is a binary semaphore used for locking in concurrent programming.
Q30. Theory of Computation
Which of the following is a universal gate?
A. AND
B. OR
C. NOT
D. NAND
Correct Answer: D
NAND and NOR are universal gates — any Boolean function can be implemented using only NAND (or only NOR) gates.
Correct Answer: C
Quicksort has worst-case O(n²) when the pivot is the smallest or largest element (e.g., already sorted array with naive pivot).