How every question is solved
- A step-by-step solution, in plain language, from the question to the answer
- The key concept or formula behind the question, so you can solve similar ones
- A fact worth remembering, to make the answer stick
- Tips and tricks to save time and avoid common mistakes
What is inside the GATE CS papers
- 20 solved GATE CS papers (2007 to 2026), each on its own or together in one book
- Subject-wise question sets: Engineering Mathematics, Algorithms, Digital Logic, Computer Organization and Architecture, Programming and Data Structures, Theory of Computation, Compiler Design, Operating System, Databases, Computer Networks, General Aptitude
- 5 full-length mock exams with answer keys
- A Key Concepts and Formula book for quick revision
Read the first questions, page after page
These are 5 pages in a row from the book, so you can read the questions in order and then the working under each one. Try each question yourself first, then follow the working and compare your steps.





Read the text of these pages
The words of the pages above, for screen readers and quick reading. Formulas and diagrams are in the pictures.
Page 19
GATE CS 2026 (Set 1) GATE CS 2026 (Set 1) Solved Paper Instruction tEX (ns) M LOAD 1.8 15 IMUL 1.5 10 IDIV 2.5 5 FADD 1.7 10 FSUB 1.7 5 FMUL 2.8 15 FDIV 3.2 5 All other instructions < 1.0 35 When program P is executed, the number of clock cycles for which the pipeline is stalled due to structural hazards in the EX stage is ______ (answer in integer). Step-by-Step Solution With a 1 ns clock, an instruction whose tEX exceeds 1 ns keeps the (single, nonreplicated) EX unit busy for tEX cycles. The following instruction cannot enter EX until it is free, so the pipeline stalls for tEX 1 cycles per such instruction. Instructions with tEX < 1 ns need no extra cycle. Instruction tEX Cycles in EX Stalls each M Stalls LOAD 1.8 2 1 15 15 IMUL 1.5 2 1 10 10 IDIV 2.5 3 2 5 10 FADD 1.7 2 1 10 10 FSUB 1.7 2 1 5 5 FMUL 2.8 3 2 15 30 FDIV 3.2 4 3 5 15 Others < 1 1 0 35 0 Total 95 Answer: 95 Key Concept / Formula to Remember Stalls per instruction = tEX/Tclk 1 when the EX stage is a single unpipelined unit. Because EX is not replicated or pipelined, the multi-cycle operations (floating-point multiply and divide in particular) account for most of the stalls. 55 GATE CS 2026 (Set 1) GATE CS 2026 (Set 1) Solved Paper Q.61 Programming and Data Structures · Recursive Functions 2 marks · NAT Question Consider the recursive functions represented by the following code segment: int bar(int n){ if (n == 1) return 0; else return 1 + bar(n/2); } int foo(int n){ if (n == 1) return 1; else return 1 + foo(bar(n)); } The smallest positive integer n for which foo(n) returns 5 is ______ (answer in integer). Note: Ignore syntax errors (if any) in the function. Step-by-Step Solution bar(n) = log2 n (the number of times n can be halved before reaching 1). Work backwards from the required value, always taking the smallest argument whose bar equals the previous argument. (Check that no smaller n works: any n with foo(n)=5 needs bar(n)≥ 16, since foo(m)≤ 4 for m < 16, hence n ≥ 2 16.) Answer: 65536 Key Concept / Formula to Remember Invert the recursion: foo(n) = k foo(log2 n) = k 1. The values 1, 2, 4, 16, 65536 are a tower of exponentials: each is 2 raised to the previous one. Q.62 Data Structures · BST Postorder from Preorder 2 marks · NAT Question The following sequence corresponds to the preorder traversal of a binary search tree T: 50, 25, 13, 40, 30, 47, 75, 60, 70, 80, 77. The position of the
Page 20
Answer: 9.5 Key Concept / Formula to Remember FCFS: waiting time = start time arrival time; start = max(arrival, previous finish). FCFS suffers from the convoy effect: later short jobs wait behind long ones, which is why the waiting times keep growing here. Q.65 Databases · Counting Superkeys 2 marks · NAT Question Consider a relational database schema with a relation R(A, B, C, D). If {A, B} and {A, C} are the only two candidate keys of the relation R, then the number of superkeys of relation R is ______ (answer in integer). Step-by-Step Solution A superkey is any attribute set that contains a candidate key. So a set is a superkey iff it contains {A, B} or {A, C}, i.e. it contains A and at least one of B, C. Let X {B, C, D} be the rest of the set: Number of subsets of {B, C, D} 8 without B and C (subsets of {D}) 2 with B or C 8 2 = 6 The six superkeys are AB, AC, ABC, ABD, ACD, ABCD. Answer: 9.5 Key Concept / Formula to Remember FCFS: waiting time = start time arrival time; start = max(arrival, previous finish). FCFS suffers from the convoy effect: later short jobs wait behind long ones, which is why the waiting times keep growing here. Q.65 Databases · Counting Superkeys 2 marks · NAT Question Consider a relational database schema with a relation R(A, B, C, D). If {A, B} and {A, C} are the only two candidate keys of the relation R, then the number of superkeys of relation R is ______ (answer in integer). Step-by-Step Solution A superkey is any attribute set that contains a candidate key. So a set is a superkey iff it contains {A, B} or {A, C}, i.e. it contains A and at least one of B, C. Let X {B, C, D} be the rest of the set: Number of subsets of {B, C, D} 8 without B and C (subsets of {D}) 2 with B or C 8 2 = 6 The six superkeys are AB, AC, ABC, ABD, ACD, ABCD. Answer: 9.5 Key Concept / Formula to Remember FCFS: waiting time = start time arrival time; start = max(arrival, previous finish). FCFS suffers from the convoy effect: later short jobs wait behind long ones, which is why the waiting times keep growing here. Q.65 Databases · Counting Superkeys 2 marks · NAT Question Consider a relational database schema with a relation R(A, B, C, D). If {A, B} and {A, C} are the only two candidate keys of the relation R, then the number of superkeys of relation R is ______ (answer in integer). Step-by-Step Solution A superkey is any attribute set that contains a ca
Page 21
GATE CS 2026 (Set 2) GATE CS 2026 (Set 2) Solved Paper Did You Know? This is the 11-cell shape the figure leaves empty: 36 25 = 11 cells. Q.3 General Aptitude · Binomial Probability 1 mark · MCQ Question A day can only be cloudy or sunny. The probability of a day being cloudy is 0.5, independent of the condition on other days. What is the probability that in any given four days, there will be three cloudy days and one sunny day? (A) 1/4 (B) 3/4 (C) 2/3 (D) 3/8 Step-by-Step Solution Each day is an independent trial with p = 0.5. The number of cloudy days in 4 days is binomial with n = 4, p = 1 2 : P(3 cloudy) = 4 3 1 2 3 1 2 1 = 4 · 1 16 = 1 4 . Answer: (A) 1/4 Key Concept / Formula to Remember Binomial: P(k) = ( n k )p k(1 p) nk ; here the 4 favourable arrangements out of 2 4 = 16. With p = 1 2 , every one of the 24 weather sequences is equally likely. Q.4 General Aptitude · Prot Computation 1 mark · MCQ Question The values of Stock A and Stock B on a particular day are Rs. He sells all the stocks the next day when the value of Stock A is Rs. The profit made by the investor is Rs. Answer: (A) 0 Key Concept / Formula to Remember Units = money invested ÷ price; profit = units × (new price old price). A rise of 10% in A and a fall of 12.5% in B cancel exactly in rupee terms here. Q.5 General Aptitude · Logical Deduction 1 mark · MCQ Question ‘When it is raining, peacocks dance.’ Based only on this sentence, which one of the following options is necessarily true? (A) Peacocks dance only when it is raining. (B) When peacocks dance, it is raining. (C) When peacocks are not dancing, it is not raining. (D) When it is not raining, peacocks do not dance. Step-by-Step Solution Let R = “it is raining” and D = “peacocks dance”. (A), (B): these say D R, the converse, which is not implied (peacocks may dance on dry days). (D): says R D, the inverse, also not implied. (C): says D R, the contrapositive, which is logically equivalent to R D: necessarily true. Answer: (C) Key Concept / Formula to Remember An implication is equivalent only to its contrapositive. Converse and inverse are equivalent to each other but not to the original statement. 6 GATE CS 2026 (Set 2) GATE CS 2026 (Set 2) Solved Paper Step-by-Step Solution Stock A: Rs. Answer: (A) 0 Key Concept / Formula to Remember Units = money invested ÷ price; profit = units × (new price old price). A rise of 10% in A and a
Page 22
GATE CS 2026 (Set 2) GATE CS 2026 (Set 2) Solved Paper Key Concept / Formula to Remember Reduce each tile to a number (count of black dots) and look for a magic-square or row-sum rule. The Lo Shu square, with all rows, columns and diagonals summing to 15, is the oldest known magic square. Q.8 General Aptitude · Hamiltonian Cycle 2 marks · MCQ Question Figures (i) and (ii) represent intercity highway systems. The black dots represent cities and the line segments between them represent intercity highways. A salesperson needs to make a trip. She needs to start from a city, visit each of the remaining cities exactly once, and finally return to the same city from which she started. Which one of the following options is then true? (Figures are representative.) (i) (ii)A B C D E (A) Such a trip is possible for (i), but not for (ii). (B) Such a trip is possible for (ii), but not for (i). (C) Such a trip is possible for both (i) and (ii). (D) Such a trip is possible neither for (i) nor for (ii). Step-by-Step Solution The trip is a Hamiltonian cycle. Figure (i) is the 4 × 4 grid graph with 16 cities. A tour exists; following the red route below visits every city once and returns to the start. 9 GATE CS 2026 (Set 2) GATE CS 2026 (Set 2) Solved Paper Figure (ii) has 5 cities. Its edges are AB, AC, AE, DE, DC, DB: every edge joins one of {A, D} to one of {B, C, E}, so the graph is the complete bipartite graph K2,3. A cycle alternates between the two sides, so it needs equal numbers of cities on each side; here 2 = 3. Hence no Hamiltonian cycle exists. (Equivalently: a tour through all 3 cities B, C, E would have to enter and leave each one through A or D, requiring at least 3 distinct neighbours among only two.) So the trip is possible for (i) but not for (ii). Answer: (A) Key Concept / Formula to Remember A bipartite graph with unequal sides has no Hamiltonian cycle. The cycle in (i) shows that every grid graph with an even number of cities has such a tour. Q.9 General Aptitude · Grid Shading Puzzle 2 marks · MCQ Question The figure in Panel I below is a grid of cells with four rows and four columns. The numbers on the top and on the left represent the number of cells that are to be shaded in that column and row, respectively. Which one of the options shown in Panel II below represents the grid shaded correctly? (Figures are representative.) Panel I 2 2 2 2 3 1 2 2 Pane
Page 23
GATE CS 2026 (Set 2) GATE CS 2026 (Set 2) Solved Paper Q.12 Data Structures · Tree Traversals 1 mark · MCQ Question The set T represents various traversals over binary tree. The set S represents the order of visiting nodes during a traversal. T S I: Inorder L: left subtree, node, right subtree II: Preorder M: node, left subtree, right subtree III: Postorder N: left subtree, right subtree, node Which one of the following is the correct match from T to S? (A) I – L, II – M, III – N (B) I – M, II – L, III – N (C) I – N, II – M, III – L (D) I – L, II – N, III – M Step-by-Step Solution The prefix tells where the node is visited relative to its subtrees: preorder visits the node first (M), inorder visits it in between the left and right subtrees (L) and postorder visits it last (N). The left subtree is always traversed before the right subtree. Answer: (A) Key Concept / Formula to Remember pre = node first, in = node in the middle, post = node last. Inorder traversal of a binary search tree gives the keys in sorted order. Q.13 Theory of Computation · Deciding a Language 1 mark · MCQ Question Which one of the following statements is equivalent to the following assertion? Turing machine M decides the language L {0, 1} . (A) Turing machine M halts on all input strings in {0, 1} (B) Turing machine M accepts all input strings in L (C) Turing machine M rejects all input strings in {0, 1} L (D) Turing machine M accepts all input strings in L and rejects all input strings in {0, 1} L 13 GATE CS 2026 (Set 2) GATE CS 2026 (Set 2) Solved Paper Q.12 Data Structures · Tree Traversals 1 mark · MCQ Question The set T represents various traversals over binary tree. The set S represents the order of visiting nodes during a traversal. T S I: Inorder L: left subtree, node, right subtree II: Preorder M: node, left subtree, right subtree III: Postorder N: left subtree, right subtree, node Which one of the following is the correct match from T to S? (A) I – L, II – M, III – N (B) I – M, II – L, III – N (C) I – N, II – M, III – L (D) I – L, II – N, III – M Step-by-Step Solution The prefix tells where the node is visited relative to its subtrees: preorder visits the node first (M), inorder visits it in between the left and right subtrees (L) and postorder visits it last (N). The left subtree is always traversed before the right subtree. Answer: (A) Key Concept / Formula to Remember pre =
The Key Concepts and Formula book
A separate book gathers the key ideas and formulae of the whole syllabus for quick revision. These pages follow one another.



Get the app
Quillwing is on the Microsoft Store for Windows. Android is coming soon. There are also topic-wise question sets and mock exams scored the moment you submit.
Android: coming soon
Other books
Quillwing is independent study material and is not connected to the bodies that conduct GATE, JEE or NEET.
