Skip to content

GATE CS question library

Practise GATE CS Computer Science previous year questions free. Browse by subject, syllabus topic, year and question type, with answers and available solutions.

Subject, topic, year and type filter the full library. Match any choice within a filter, and all selected filter categories. Search, source and sort apply to this page.

20 on this page
Official PYQ2025Programming and Data StructuresRecursionNAT · 2 marks
#include <stdio.h> int foo(int S[],int size) { if(size == 0) return 0; if(size == 1) return 1; if(S[0] != S[1]) return 1+foo(S+1,size-1); return foo(S+1,size-1); } int main() { int A[]={0,1,2,2,2,0,0,1,1}; printf("%d",foo(A,9)); return 0; } The value printed by the given CC program is ___________. (Answer in integer)
Official PYQ2025Programming and Data StructuresLinked ListsNAT · 2 marks
Let LIST\mathrm{LIST} be a datatype for an implementation of linked list defined as follows: typedef struct list { int data; struct list *next; } LIST; Suppose a program has created two linked lists, L1L1 and L2L2, whose contents are given in the figure below (code for creating L1L1 and L2L2 is not provided here). L1L1 contains 99 nodes, and …
Official PYQ2025Programming and Data StructuresProgramming in CNAT · 2 marks
Consider the following C program: #include <stdio.h> int gate (int n) { int d, t, newnum, turn; newnum = turn = 0; t=1; while (n>=t) t *= 10; t /=10; while (t>0) { d = n/t; n = n%t; t /= 10; if (turn) newnum = 10*newnum + d; turn = (turn + 1) % 2; } return newnum; } int main () { printf ("%d", gate(14362)); return 0; } The value printed by the …
Official PYQ2025AlgorithmsMinimum Spanning TreesNAT · 2 marks
The maximum value of x\text{x} such that the edge between the nodes B\text{B} and C\text{C} is included in every minimum spanning tree of the given graph is _________. (answer in integer)
Official PYQ2025AlgorithmsSearching, Sorting, HashingNAT · 2 marks
In a double hashing scheme, h1(k)=k mod 11h_{1}(k)=k \bmod 11 and h2(k)=1+(k mod 7)h_{2}(k)=1+(k \bmod 7) are the auxiliary hash functions. The size mm of the hash table is 1111. The hash function for the ii-th probe in the open address table is [h1(k)+ih2(k)] mod m\left[h_{1}(k)+i h_{2}(k)\right] \bmod m. The following keys are inserted in the given order: 63,50,25,79,67,2463,50,25,79,67,24. The slot …
Official PYQ2025Compiler DesignParsing (LL, LR)MSQ · 2 marks
Consider two grammars G1G_{1} and G2G_{2} with the production rules given below: G1:S→G_{1} : S \rightarrow ifif EE thenthen SS ∣| ifif EE thenthen SS elseelse SS ∣| aa E→bE \rightarrow b G2:S→G_{2} :S \rightarrow ifif EE thenthen SS ∣| MM M→M \rightarrow ifif EE thenthen MM elseelse SS ∣| cc …
Official PYQ2025Theory of ComputationRegular and Context-free LanguagesMSQ · 2 marks
Let Σ={a,b,c}\Sigma=\{a, b, c\}. For x∈Σ∗x \in \Sigma^{*}, and α∈Σ\alpha \in \Sigma, let #α(x)\#_{\alpha}(x) denote the number of occurrences of α\alpha in xx. Which one or more of the following option(s) define(s) regular language(s)?
Official PYQ2025DatabasesTransactions and Concurrency ControlMCQ · 2 marks
Consider the database transactions T1 and T2 , and data items X and Y . Which of the schedule(s) is/are conflict serializable? …
Official PYQ2025DatabasesTuple Calculus and SQLMSQ · 2 marks
Consider the following relational schema: Students (rollno: integer‾,\underline{\text{rollno: integer}}, name: string, age: integer, cgpa: real) Courses (courseno: integer‾,\underline{\text{courseno: integer}}, cname: string, credits: integer) Enrolled (rollno: integer‾,\underline{\text{rollno: integer}}, courseno: integer‾,\underline{\text{courseno: integer}}, grade: string) Which of the following options is/are …
Official PYQ2025Computer Organization and ArchitectureMemory Hierarchy: Cache, Main Memory and Secondary StorageNAT · 2 marks
Given a computing system with two levels of cache (L1 and L2) and a main memory. The first level (L1) cache access time is 11 nanosecond (ns) and the "hit rate" for L1 cache is 90%90 \% while the processor is accessing the data from L1 cache. Whereas, for the second level (L2) cache, the "hit rate" is 80%80 \% and the "miss penalty" for transferring …
Official PYQ2025Computer Organization and ArchitectureInstruction PipeliningNAT · 2 marks
A 55-stage instruction pipeline has stage delays of 180,250,150,170180,250,150,170, and 250250, respectively, in nanoseconds. The delay of an inter-stage latch is 1010 nanoseconds. Assume that there are no pipeline stalls due to branches and other hazards. The time taken to process 10001000 instructions in microseconds is __________. (rounded off to two decimal …
Official PYQ2025DatabasesFile Organization and Indexing (B and B+ Trees)NAT · 2 marks
In a B+\mathrm{B}^{+}- tree where each node can hold at most four key values, a root to leaf path consists of the following nodes: A=(49,77,83,−),B=(7,19,33,44),C=(20∗,22∗,25∗,26∗)\mathrm{A}=(49,77,83,-), \mathrm{B}=(7,19,33,44), \mathrm{C}=\left(20^{*}, 22^{*}, 25^{*}, 26^{*}\right) The ∗*-marked keys signify that these are data entries in a leaf. Assume that a pointer between keys k1k_{1} and …
Official PYQ2025Operating SystemMemory Management and Virtual MemoryNAT · 2 marks
A computer system supports a logical address space of 2322^{32} bytes. It uses two-level hierarchical paging with a page size of 40964096 bytes. A logical address is divided into a bb-bit index to the outer page table, an offset within the page of the inner page table, and an offset within the desired page. Each entry of the inner page table uses eight …
Official PYQ2025AlgorithmsGraph Traversals (BFS, DFS)NAT · 2 marks
Consider the following algorithm someAlgo that takes an undirected graph GG as input. someAlgo (G) Let vv be any vertex in GG. Run BFS on GG starting at vv. Let uu be a vertex in GG at maximum distance from vv as given by the BFS. Run BFS on GG again with uu as the starting vertex. Let zz be the vertex at maximum distance …
Official PYQ2025Theory of ComputationRegular Expressions and Finite AutomataNAT · 2 marks
Let Σ={1,2,3,4}\Sigma=\{1,2,3,4\}. For x∈Σ∗x \in \Sigma^{*}, let prod⁡(x)\operatorname{prod}(x) be the product of symbols in xx modulo 7. We take prod⁡(ϵ)=1\operatorname{prod}(\epsilon)=1, where ϵ\epsilon is the null string. For example, prod⁡(124)=(1×2×4) mod 7=1\operatorname{prod}(124)=(1 \times 2 \times 4) \bmod 7=1. Define …
Official PYQ2025Computer Organization and ArchitectureMachine Instructions and Addressing ModesNAT · 2 marks
An application executes 6.4×1086.4 \times 10^{8} number of instructions in 6.36.3 seconds. There are four types of instructions, the details of which are given in the table. The duration of a clock cycle in nanoseconds is __________. (rounded off to one decimal place) …
Official PYQ2025Programming and Data StructuresProgramming in CNAT · 2 marks
Consider the following C program: #include<stdio.h> int main(){ int a; int arr[5] = {30,50,10}; int *ptr; ptr = &arr[0] + 1; a = *ptr; (*ptr)++; ptr++; printf("%d", a + (*ptr) + arr[1]); return 0; } The output of the above program is _________. (Answer in integer)
Official PYQ2025Programming and Data StructuresProgramming in CNAT · 2 marks
Consider the following C program: #include <stdio.h> int g(int n) { return (n+10); } int f(int n) { return g(n*2); } int main() { int sum, n; sum=0; for (n=1; n<3; n++) sum += g(f(n)); printf ("%d", sum); return 0; } The output of the given C program is ___________. (Answer in integer)
Official PYQ2025Engineering MathematicsProbability: Random Variables and DistributionsNAT · 2 marks
A quadratic polynomial (x−α)(x−β)(x-\alpha)(x-\beta) over complex numbers is said to be square invariant if (x−α)(x−β)=(x−α2)(x−β2)(x-\alpha)(x-\beta)=\left(x-\alpha^{2}\right)\left(x-\beta^{2}\right). Suppose from the set of all square invariant quadratic polynomials we choose one at random. The probability that the roots of the chosen polynomial are equal is __________. (rounded …
Official PYQ2025Engineering MathematicsProbability: Random Variables and DistributionsNAT · 2 marks
The unit interval (0,1)(0,1) is divided at a point chosen uniformly distributed over (0,1)(0,1) in R\mathbb{R} into two disjoint subintervals. The expected length of the subinterval that contains 0.40.4 is __________. (rounded off to two decimal places)