GATE CS 2025 Set-1

65 questions · 100 marks · MCQ / MSQ / NAT with official GATE marking

Q1 · MCQ1 markGAGeneral Aptitude

Ravi had ______ younger brother who taught at ______ university. He was widely regarded as ______ honorable man. Select the option with the correct sequence of articles to fill in the blanks.

Q2 · MCQ1 markGAGeneral Aptitude

The CEO's decision to downsize the workforce was considered myopic because it sacrificed long-term stability to accommodate short-term gains. Select the most appropriate option that can replace the word "myopic" without changing the meaning of the sentence.

Q3 · MCQ1 markGAGeneral Aptitude

The average marks obtained by a class in an examination were calculated as 30.8. However, while checking the marks entered, the teacher found that the marks of one student were entered incorrectly as 24 instead of 42. After correcting the marks, the average becomes 31.4. How many students does the class have?

Q4 · MCQ1 markGAGeneral Aptitude

Consider the relationships among P, Q, R, S, and T: - P is the brother of Q. - S is the daughter of Q. - T is the sister of S. - R is the mother of Q. The following statements are made based on the relationships given above. (1) R is the grandmother of S. (2) P is the uncle of S and T. (3) R has only one son. (4) Q has only one daughter. Which one of the following options is correct?

Q5 · MCQ1 markGAGeneral Aptitude

According to the map described below, which one of the following statements is correct? Two roads cross each other. 1st Main Road runs north to south. 5th Cross Road runs east to west. This makes four blocks. - North-west block: Library, with the Physics Lab just south of it. - North-east block: Canteen, with the Hospital just south of it. - South-west block: Hostels, with the Classrooms just south of them. - South-east block: Chemistry Lab. (North is at the top of the map.)

Q6 · MCQ2 marksGAGeneral Aptitude

"I put the brown paper in my pocket along with the chalks, and possibly other things. I suppose every one must have reflected how primeval and how poetical are the things that one carries in one's pocket: the pocket-knife, for instance the type of all human tools, the infant of the sword. Once I planned to write a book of poems entirely about the things in my pocket. But I found it would be too long: and the age of the great epics is past." (From G.K. Chesterton's "A Piece of Chalk") Based only on the information provided in the above passage, which one of the following statements is true?

Q7 · MCQ2 marksGAGeneral Aptitude

In a triangle PQR, the point S lies on PQ and the point T lies on PR, so that the line ST is parallel to QR. The shortest distance between the lines QR and ST is half the shortest distance between the point P and line QR. What is the ratio of the area of the triangle PST to the area of the trapezium SQRT?

Q8 · MCQ2 marksGAGeneral Aptitude

A fair six-faced dice, with the faces labelled '1', '2', '3', '4', '5', and '6', is rolled thrice. What is the probability of rolling '6' exactly once?

Q9 · MCQ2 marksGAGeneral Aptitude

A square paper, shown in figure (I), is folded along the dotted lines as shown in the figures (II) and (III). Then a few cuts are made as shown in figure (IV). Which one of the following patterns will be obtained when the paper is unfolded?

Q10 · MCQ2 marksGAGeneral Aptitude

A shop has 4 distinct flavors of ice-cream. One can purchase any number of scoops of any flavor. The order in which the scoops are purchased is inconsequential. If one wants to purchase 3 scoops of ice-cream, in how many ways can one make that purchase?

Q11 · MCQ1 markCSComputer Organization and Architecture

Suppose a program is running on a non-pipelined single processor computer system. The computer is connected to an external device that can interrupt the processor asynchronously. The processor needs to execute the interrupt service routine (ISR) to serve this interrupt. The following steps (not necessarily in order) are taken by the processor when the interrupt arrives: (i) The processor saves the content of the program counter. (ii) The program counter is loaded with the start address of the ISR. (iii) The processor finishes the present instruction. Which ONE of the following is the CORRECT sequence of steps?

Q12 · MCQ1 markCSCompiler Design

Which ONE of the following statements is FALSE regarding the symbol table?

Q13 · MCQ1 markCSCompiler Design

Which ONE of the following techniques used in compiler code optimization uses live variable analysis?

Q14 · MCQ1 markCSOperating Systems

Consider a demand paging memory management system with 32-bit logical address, 20-bit physical address, and page size of 2048 bytes. Assuming that the memory is byte addressable, what is the maximum number of entries in the page table?

Q15 · MCQ1 markCSDBMS

A schedule of three database transactions T1, T2, and T3 is shown. Ri(A) and Wi(A) denote read and write of data item A by transaction Ti, i = 1, 2, 3. The transaction T1 aborts at the end. Which other transaction(s) will be required to be rolled back? R1(X) W1(Y) R2(X) R2(Y) R3(Y) ABORT(T1)

Q16 · MCQ1 markCSComputer Networks

Identify the ONE CORRECT matching between the OSI layers and their corresponding functionalities as shown. OSI Layers: (a) Network layer, (b) Transport layer, (c) Datalink layer Functionalities: (I) Packet routing, (II) Framing and error handling, (III) Host to host communication

Q17 · MCQ1 markCSEngineering Mathematics

g(.) is a function from A to B, f(.) is a function from B to C, and their composition defined as f(g(.)) is a mapping from A to C. If f(.) and f(g(.)) are onto (surjective) functions, which ONE of the following is TRUE about the function g(.)?

Q18 · MCQ1 markCSAlgorithms

Let G be any undirected graph with positive edge weights, and T be a minimum spanning tree of G. For any two vertices, u and v, let d1(u, v) and d2(u, v) be the shortest distances between u and v in G and T, respectively. Which ONE of the options is CORRECT for all possible G, T, u and v?

Q19 · MCQ1 markCSTheory of Computation

Consider the following context-free grammar G, where S, A, and B are the variables (non-terminals), a and b are the terminal symbols, S is the start variable, and the rules of G are described as: S → aaB | Abb A → a | aA B → b | bB Which ONE of the languages L(G) is accepted by G?

Q20 · MCQ1 markCSAlgorithms

Consider the following recurrence relation: T(n) = 2T(n - 1) + n·2ⁿ for n > 0, T(0) = 1. Which ONE of the following options is CORRECT?

Q21 · MSQ1 markCSDBMS

Consider the following B+ tree with 5 nodes, in which a node can store at most 3 key values. The value 23 is now inserted in the B+ tree. Which of the following option(s) is/are CORRECT? Root: [6 | 12 | 19] Leaves, left to right: [1 | 4 | 3], [7 | 9 | 10], [13 | 15 | 17], [20 | 21 | 22]

Q22 · MSQ1 markCSComputer Networks

Consider the 3-way handshaking protocol for TCP connection establishment. Let the three packets exchanged during the connection establishment be denoted as P1, P2, and P3, in order. Which of the following option(s) is/are TRUE with respect to TCP header flags that are set in the packets?

Q23 · MSQ1 markCSEngineering Mathematics

Consider the given system of linear equations for variables x and y, where k is a real-valued constant. Which of the following option(s) is/are CORRECT? x + ky = 1 kx + y = -1

Q24 · MSQ1 markCSDigital Logic

Let X be a 3-variable Boolean function that produces output as '1' when at least two of the input variables are '1'. Which of the following statement(s) is/are CORRECT, where a, b, c, d, e are Boolean variables?

Q25 · MSQ1 markCSDigital Logic

The number -6 can be represented as 1010 in 4-bit 2's complement representation. Which of the following is/are CORRECT 2's complement representation(s) of -6?

Q26 · MSQ1 markCSProgramming and Data Structures

Which of the following statement(s) is/are TRUE for any binary search tree (BST) having n distinct integers?

Q27 · MSQ1 markCSComputer Organization and Architecture

A partial data path of a processor is given in the figure, where RA, RB, and RZ are 32-bit registers. Which option(s) is/are CORRECT related to arithmetic operations using the data path as shown? Figure description: Mux_A chooses between register RA and a 32-bit immediate value (control: Select RA/immediate). Mux_B chooses between register RB and a 32-bit immediate value (control: Select RB/immediate). The outputs of Mux_A and Mux_B are the two inputs of the ALU, which has ALU control lines. The ALU output is stored in RZ.

Q28 · MSQ1 markCSTheory of Computation

A regular language L is accepted by a non-deterministic finite automaton (NFA) with n states. Which of the following statement(s) is/are FALSE?

Q29 · NAT1 markCSOperating Systems

Suppose in a multiprogramming environment, the following C program segment is executed. A process goes into I/O queue whenever an I/O related operation is performed. Assume that there will always be a context switch whenever a process requests for an I/O, and also whenever the process returns from an I/O. The number of times the process will enter the ready queue during its lifetime (not counting the time the process enters the ready queue when it is run initially) is _______. (Answer in integer) int main() { int x=0,i=0; scanf("%d",&x); for(i=0; i<20; i++) { x = x+20; printf("%d\n",x); } return 0; }

Q30 · NAT1 markCSEngineering Mathematics

Let S be the set of all ternary strings defined over the alphabet {a, b, c}. Consider all strings in S that contain at least one occurrence of two consecutive symbols, that is, "aa", "bb" or "cc". The number of such strings of length 5 that are possible is _______. (Answer in integer)

Q31 · NAT1 markCSEngineering Mathematics

Consider the given function f(x). f(x) = ax + b, for x < 1 f(x) = x³ + x² + 1, for x ≥ 1 If the function is differentiable everywhere, the value of b must be ________. (rounded off to one decimal place)

Q32 · NAT1 markCSEngineering Mathematics

A box contains 5 coins: 4 regular coins and 1 fake coin. When a regular coin is tossed, the probability P(head) = 0.5 and for a fake coin, P(head) = 1. You pick a coin at random and toss it twice, and get two heads. The probability that the coin you have chosen is the fake coin is _______. (rounded off to two decimal places)

Q33 · NAT1 markCSProgramming and Data Structures

The pseudocode of a function fun() is given below: fun(int A[0,...,n-1]){ for i=0 to n-2 for j=0 to n-i-2 if (A[j]>A[j+1]) then swap A[j] and A[j+1] } Let A[0,...,29] be an array storing 30 distinct integers in descending order. The number of swap operations that will be performed, if the function fun() is called with A[0,...,29] as argument, is __________. (Answer in integer)

Q34 · NAT1 markCSProgramming and Data Structures

#include <stdio.h> void foo(int *p, int x){ *p=x; } int main(){ int *z; int a = 20, b = 25; z = &a; foo(z,b); printf("%d",a); return 0; } The output of the given C program is __________. (Answer in integer)

Q35 · NAT1 markCSProgramming and Data Structures

The height of any rooted tree is defined as the maximum number of edges in the path from the root node to any leaf node. Suppose a Min-Heap T stores 32 keys. The height of T is _____________. (Answer in integer)

Q36 · MCQ2 marksCSComputer Organization and Architecture

Consider a memory system with 1M bytes of main memory and 16K bytes of cache memory. Assume that the processor generates 20-bit memory address, and the cache block size is 16 bytes. If the cache uses direct mapping, how many bits will be required to store all the tag values? [Assume memory is byte addressable, 1K = 2¹⁰, 1M = 2²⁰.]

Q37 · MCQ2 marksCSComputer Organization and Architecture

A processor has 64 general-purpose registers and 50 distinct instruction types. An instruction is encoded in 32-bits. What is the maximum number of bits that can be used to store the immediate operand for the given instruction? ADD R1, #25 // R1 = R1 + 25

Q38 · MCQ2 marksCSOperating Systems

A computer has two processors, M1 and M2. Four processes P1, P2, P3, P4 with CPU bursts of 20, 16, 25, and 10 milliseconds, respectively, arrive at the same time and these are the only processes in the system. The scheduler uses non-preemptive priority scheduling, with priorities decided as follows: - M1 uses priority of execution for the processes as, P1 > P3 > P2 > P4, i.e., P1 and P4 have highest and lowest priorities, respectively. - M2 uses priority of execution for the processes as, P2 > P3 > P4 > P1, i.e., P2 and P1 have highest and lowest priorities, respectively. A process Pi is scheduled to a processor Mk, if the processor is free and no other process Pj is waiting with higher priority. At any given point of time, a process can be allocated to any one of the free processors without violating the execution priority rules. Ignore the context switch time. What will be the average waiting time of the processes in milliseconds?

Q39 · MCQ2 marksCSDBMS

Consider two relations describing teams and players in a sports league: - teams(tid, tname): tid, tname are team-id and team-name, respectively - players(pid, pname, tid): pid, pname, and tid denote player-id, player-name and the team-id of the player, respectively Which ONE of the following tuple relational calculus queries returns the name of the players who play for the team having tname as 'MI'?

Q40 · MCQ2 marksCSComputer Networks

A packet with the destination IP address 145.36.109.70 arrives at a router whose routing table is shown. Which interface will the packet be forwarded to? Subnet Address | Subnet Mask (CIDR) | Interface 145.36.0.0 | /16 | E1 145.36.128.0 | /17 | E2 145.36.64.0 | /18 | E3 145.36.255.0 | /24 | E4 Default | -- | E5

Q41 · MCQ2 marksCSEngineering Mathematics

Let A be a 2 × 2 matrix as given. A = [ 1 1 ] [ 1 -1 ] What are the eigenvalues of the matrix A¹³?

Q42 · MCQ2 marksCSDigital Logic

Consider the following four variable Boolean function in sum-of-product form F(b3, b2, b1, b0) = Σ(0, 2, 4, 8, 10, 11, 12) where the value of the function is computed by considering b3b2b1b0 as a 4-bit binary number, where b3 denotes the most significant bit and b0 denotes the least significant bit. Note that there are no don't care terms. Which ONE of the following options is the CORRECT minimized Boolean expression for F? (Here x' means NOT x.)

Q43 · MCQ2 marksCSAlgorithms

Let G(V, E) be an undirected and unweighted graph with 100 vertices. Let d(u, v) denote the number of edges in a shortest path between vertices u and v in V. Let the maximum value of d(u, v), u, v ∈ V such that u ≠ v, be 30. Let T be any breadth-first-search tree of G. Which ONE of the given options is CORRECT for every such graph G?

Q44 · MCQ2 marksCSTheory of Computation

Consider the following two languages over the alphabet {a, b}: L1 = { αβα | α ∈ {a, b}⁺ AND β ∈ {a, b}⁺ } L2 = { αβα | α ∈ {a}⁺ AND β ∈ {a, b}⁺ } Which ONE of the following statements is CORRECT?

Q45 · MCQ2 marksCSTheory of Computation

Consider the following two languages over the alphabet {a, b, c}, where m and n are natural numbers. L1 = { aᵐbᵐcᵐ⁺ⁿ | m, n ≥ 1 } L2 = { aᵐbⁿcᵐ⁺ⁿ | m, n ≥ 1 } Which ONE of the following statements is CORRECT?

Q46 · MSQ2 marksCSCompiler Design

Which of the following statement(s) is/are TRUE while computing First and Follow during top down parsing by a compiler?

Q47 · MSQ2 marksCSDBMS

Consider a relational schema team(name, city, owner), with functional dependencies {name → city, name → owner}. The relation team is decomposed into two relations, t1(name, city) and t2(name, owner). Which of the following statement(s) is/are TRUE?

Q48 · MSQ2 marksCSEngineering Mathematics

Which of the following predicate logic formulae/formula is/are CORRECT representation(s) of the statement: "Everyone has exactly one mother"? The meanings of the predicates used are: - mother(y, x): y is the mother of x - noteq(x, y): x and y are not equal

Q49 · MSQ2 marksCSEngineering Mathematics

A = {0, 1, 2, 3, ...} is the set of non-negative integers. Let F be the set of functions from A to itself. For any two functions, f1, f2 ∈ F, we define (f1 ⊙ f2)(n) = f1(n) + f2(n) for every number n in A. Which of the following is/are CORRECT about the mathematical structure (F, ⊙)?

Q50 · MSQ2 marksCSTheory of Computation

Consider the following deterministic finite automaton (DFA) defined over the alphabet, Σ = {a, b}. Identify which of the following language(s) is/are accepted by the given DFA. DFA (q0 is the start state, q3 is the only accepting state): - q0: on a go to q0, on b go to q1 - q1: on a go to q2, on b go to q1 - q2: on a go to q0, on b go to q3 - q3: on a go to q2, on b go to q1

Q51 · NAT2 marksCSOperating Systems

A disk of size 512M bytes is divided into blocks of 64K bytes. A file is stored in the disk using linked allocation. In linked allocation, each data block reserves 4 bytes to store the pointer to the next data block. The link part of the last data block contains a NULL pointer (also of 4 bytes). Suppose a file of 1M bytes needs to be stored in the disk. Assume, 1K = 2¹⁰ and 1M = 2²⁰. The amount of space in bytes that will be wasted due to internal fragmentation is ______. (Answer in integer)

Q52 · NAT2 marksCSCompiler Design

Refer to the given 3-address code sequence. This code sequence is split into basic blocks. The number of basic blocks is ________. (Answer in integer) 1001: i = 1 1002: j = 1 1003: t1 = 10*i 1004: t2 = t1+j 1005: t3 = 8*t2 1006: t4 = t3-88 1007: a[t4] = 0.0 1008: j = j+1 1009: if j <= 10 goto 1003 1010: i = i+1 1011: if i <= 10 goto 1002 1012: i = 1 1013: t5 = i-1 1014: t6 = 88*t5 1015: a[t6] = 1.0 1016: i = i+1 1017: if i <= 10 goto 1013

Q53 · NAT2 marksCSComputer Organization and Architecture

A computer has a memory hierarchy consisting of two-level cache (L1 and L2) and a main memory. If the processor needs to access data from memory, it first looks into L1 cache. If the data is not found in L1 cache, it goes to L2 cache. If it fails to get the data from L2 cache, it goes to main memory, where the data is definitely available. Hit rates and access times of various memory units are given below. The average memory access time in nanoseconds (ns) is ________. (rounded off to two decimal places) - L1 cache: hit rate = 95%, access time = 10 ns - L2 cache: hit rate = 85%, access time (including L1 cache miss penalty) = 20 ns - Main memory: access time (including L1 and L2 cache miss penalty) = 200 ns

Q54 · NAT2 marksCSOperating Systems

In optimal page replacement algorithm, information about all future page references is available to the operating system (OS). A modification of the optimal page replacement algorithm is as follows: The OS correctly predicts only up to next 4 page references (including the current page) at the time of allocating a frame to a page. A process accesses the pages in the following order of page numbers: 1, 3, 2, 4, 2, 3, 1, 2, 4, 3, 1, 4. If the system has three memory frames that are initially empty, the number of page faults that will occur during execution of the process is ________. (Answer in integer)

Q55 · NAT2 marksCSDBMS

Consider the following database tables of a sports league. player(pid, pname, age) team(tid, tname, city, cid) coach(cid, cname) members(pid, tid) An instance of the tables and an SQL query are given. player: (1, Jasprit, 31), (2, Atharva, 24), (3, Ishan, 26), (4, Axar, 30) coach: (101, Ricky), (102, Mark), (103, Trevor) team: (10, MI, Mumbai, 102), (20, DC, Delhi, 101), (30, PK, Mohali, 103) members: (1, 10), (2, 30), (3, 10), (4, 20) SELECT MIN(P.age) FROM player P WHERE P.pid IN ( SELECT M.pid FROM team T, coach C, members M WHERE C.cname = 'Mark' AND T.cid = C.cid AND M.tid = T.tid ) The value returned by the given SQL query is ______. (Answer in integer)

Q56 · NAT2 marksCSEngineering Mathematics

Suppose a 5-bit message is transmitted from a source to a destination through a noisy channel. The probability that a bit of the message gets flipped during transmission is 0.01. Flipping of each bit is independent of one another. The probability that the message is delivered error-free to the destination is ______. (rounded off to three decimal places)

Q57 · NAT2 marksCSComputer Networks

Suppose a message of size 15000 bytes is transmitted from a source to a destination using IPv4 protocol via two routers as shown in the figure. Each router has a defined maximum transmission unit (MTU) as shown in the figure, including IP header. The number of fragments that will be delivered to the destination is ________. (Answer in integer) Path: Source → Router-1 (MTU = 5000 bytes) → Router-2 (MTU = 3000 bytes) → Destination

Q58 · NAT2 marksCSEngineering Mathematics

Consider a probability distribution given by the density function P(x). P(x) = Cx², for 1 ≤ x ≤ 4 P(x) = 0, for x < 1 or x > 4 The probability that x lies between 2 and 3, i.e., P(2 ≤ x ≤ 3) is __________. (rounded off to three decimal places)

Q59 · NAT2 marksCSDigital Logic

Consider a finite state machine (FSM) with one input X and one output f, represented by the given state transition table. The minimum number of states required to realize this FSM is ________. (Answer in integer) Present state | Next state (X=0) | Next state (X=1) | Output f (X=0) | Output f (X=1) A | F | B | 0 | 0 B | D | C | 0 | 0 C | F | E | 0 | 0 D | G | A | 1 | 0 E | D | C | 0 | 0 F | F | B | 1 | 1 G | G | H | 0 | 1 H | G | A | 1 | 0

Q60 · NAT2 marksCSDigital Logic

Consider the given sequential circuit designed using D-Flip-flops. The circuit is initialized with some value (initial state). The number of distinct states the circuit will go through before returning back to the initial state is _________. (Answer in integer) Circuit description: four D flip-flops D0, D1, D2, D3 share one clock. Q0 drives the D input of D1, Q1 drives D2, and Q2 drives D3. The complemented output Q3' of the last flip-flop is fed back to the D input of D0.

Q61 · NAT2 marksCSProgramming and Data Structures

#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 C program is _______. (Answer in integer)

Q62 · NAT2 marksCSProgramming and Data Structures

Let 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, L1 and L2, whose contents are given below (code for creating L1 and L2 is not provided here). L1 contains 9 nodes, and L2 contains 7 nodes. L1: 1 → 7 → 12 → 3 → 9 → 5 → 11 → 15 → 8 → NULL L2: 1 → 11 → 6 → 9 → 15 → 12 → 4 → NULL Consider the following C program segment that modifies the list L1. The number of nodes that will be there in L1 after the execution of the code segment is ________. (Answer in integer) int find (int query, LIST *list) { while (list != NULL){ if(list->data == query) return 1; list = list->next; } return 0; } int main () { ... ptr1=L1; ptr2=L2; while (ptr1->next != NULL){ query = ptr1->next->data; if (find (query, L2)) ptr1->next = ptr1->next->next; else ptr1 = ptr1->next; } ... return 0; }

Q63 · NAT2 marksCSProgramming and Data Structures

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 given C program is _______. (Answer in integer)

Q64 · NAT2 marksCSAlgorithms

The maximum value of x such that the edge between the nodes B and C is included in every minimum spanning tree of the given graph is _________. (answer in integer) Graph: vertices A, B, C, D with edges A-B = 7, A-D = 6, A-C = 1, B-D = 3, D-C = 8, and B-C = x.

Q65 · NAT2 marksCSProgramming and Data Structures

In a double hashing scheme, h1(k) = k mod 11 and h2(k) = 1 + (k mod 7) are the auxiliary hash functions. The size m of the hash table is 11. The hash function for the i-th probe in the open address table is [h1(k) + i·h2(k)] mod m. The following keys are inserted in the given order: 63, 50, 25, 79, 67, 24. The slot at which key 24 gets stored is ___________. (Answer in integer)