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 PYQ2003Programming and Data StructuresProgramming in CMCQ · 1 mark
The following program fragment is written in a programming language that allows global variables and does not allow nested declarations of functions. global int i=100, j=5; void P(x) { int i=10; print(x+10); i=200; j=20; print (x); } main() {P(i+j);} If the programming language uses static scoping and call by need parameter passing mechanism, the values …
Official PYQ2003Engineering MathematicsPropositional and First Order LogicMCQ · 1 mark
The following resolution rule is used in logic programming. Derive clause (P∨Q)(P \vee Q) from clauses (P∨R),(Q∨¬R)(P\vee R),(Q \vee ¬R) Which of the following statements related to this rule is FALSE?
Official PYQ2003AlgorithmsGraph Traversals (BFS, DFS)MCQ · 1 mark
Let G=(V,E)G= (V,E) be a directed graph with nn vertices. A path from viv_i to vjv_j in GG is a sequence of vertices (vi,vi+1,…,vjv_{i},v_{i+1}, \dots , v_j) such that (vk,vk+1)∈E(v_k, v_{k+1}) \in E for all kk in ii through j−1j-1. A simple path is a path in which no vertex appears more than once. Let AA be an n×nn \times n array initialized as follows: …
Official PYQ2003AlgorithmsAlgorithm Design: Greedy TechniquesMCQ · 1 mark
The following are the starting and ending times of activities A,B,C,D,E,F,GA, B, C, D, E, F, G and HH respectively in chronological order: “as bs cs ae ds ce es fs be de gs ee fe hs ge he”“a_s \: b_s \: c_s \: a_e \: d_s \: c_e \: e_s \: f_s \: b_e \: d_e \: g_s \: e_e \: f_e \: h_s \: g_e \: h_e”. Here, xsx_s denotes the starting time and xex_e denotes the ending time of activity X. We need to schedule …
Official PYQ2003AlgorithmsMinimum Spanning TreesMCQ · 1 mark
What is the weight of a minimum spanning tree of the following graph?
Official PYQ2003AlgorithmsShortest Paths (Dijkstra, Bellman-Ford)MCQ · 1 mark
Let G=(V,E)G =(V,E) be an undirected graph with a subgraph G1=(V1,E1)G_1 = (V_1, E_1). Weights are assigned to edges of GG as follows. w(e)={0, if e∈E11, otherwisew(e) = \begin{cases} 0 \text{, if } e \in E_1 \\1 \text{, otherwise} \end{cases} A single-source shortest path algorithm is executed on the weighted graph (V,E,w)(V,E,w) with an arbitrary vertex v1v_1 of V1V_1 as the source. …
Official PYQ2003DatabasesFile Organization and Indexing (B and B+ Trees)MCQ · 1 mark
Consider the following 2−3−42-3-4 tree (i.e., B-tree with a minimum degree of two) in which each data item is a letter. The usual alphabetical ordering of letters is used in constructing the tree. What is the result of inserting GG in the above tree?
Official PYQ2003Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
Let S be a stack of size n≥1n \geq1. Starting with the empty stack, suppose we push the first n natural numbers in sequence, and then perform nn pop operations. Assume that Push and Pop operations take XX seconds each, and YY seconds elapse between the end of one such stack operation and the start of the next operation. For m≥1m \geq1, define the …
Official PYQ2003Programming and Data StructuresBinary Search TreesMCQ · 1 mark
A data structure is required for storing a set of integers such that each of the following operations can be done in O(log⁡n)O(\log n) time, where nn is the number of elements in the set. Deletion of the smallest element Insertion of an element if it is not already present in the set Which of the following data structures can be used for this purpose?
Official PYQ2003AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
In a permutation a1...ana_1 ... a_n, of n distinct integers, an inversion is a pair (ai,aj)(a_i, a_j) such that i<ji < j and ai>aja_i > a_j. If all permutations are equally likely, what is the expected number of inversions in a randomly chosen permutation of 1...n1. . . n?
Official PYQ2003Engineering MathematicsProbability: Random Variables and DistributionsMCQ · 1 mark
A program consists of two modules executed sequentially. Let f1(t)f_1(t) and f2(t)f_2(t) respectively denote the probability density functions of time taken to execute the two modules. The probability density function of the overall time taken to execute the program is given by
Official PYQ2003Compiler DesignSyntax-directed TranslationMCQ · 1 mark
Consider the syntax directed definition shown below. …
Official PYQ2003Compiler DesignParsing (LL, LR)MCQ · 1 mark
Consider the translation scheme shown below. S→T  RS \rightarrow T\;R R→+T{print(‘+’);}R∣εR \rightarrow + T \{\text{print}(‘+’);\} R\mid \varepsilon T→T \rightarrow num {print\{\text{print}(num.val);};\} Here num is a token that represents an integer and num.val represents the corresponding integer value. For an input string ‘9+5+29 + 5 + 2’, this translation scheme will …
Official PYQ2003Compiler DesignParsing (LL, LR)MCQ · 1 mark
Consider the grammar shown below. S→C CS \rightarrow C \ C C→c C∣dC \rightarrow c \ C \mid d This grammar is
Official PYQ2003Theory of ComputationRegular Expressions and Finite AutomataMCQ · 1 mark
Consider the NFA MM shown below. Let the language accepted by MM be LL. Let L1L_1 be the language accepted by the NFA M1M_1 obtained by changing the accepting state of MM to a non-accepting state and by changing the non-accepting states of MM to accepting states. Which of the following statements is true?
Official PYQ2003Theory of ComputationUndecidabilityMCQ · 1 mark
A single tape Turing Machine MM has two states q0q0 and q1q1, of which q0q0 is the starting state. The tape alphabet of MM is {0,1,B}\{0, 1, B\} and its input alphabet is {0,1}\{0, 1\}. The symbol BB is the blank symbol used to indicate end of an input string. The transition function of MM is described in the following table. …
Official PYQ2003Theory of ComputationContext-free Grammars and Push-down AutomataMCQ · 1 mark
Let G=({S},{a,b},R,S)G=\left(\left\{S\right\}, \left\{a,b\right\},R,S\right) be a context free grammar where the rule set R is S→aSb∣SS∣ϵS \to a S b \mid S S \mid \epsilon Which of the following statements is true?
Official PYQ2003Theory of ComputationRegular Expressions and Finite AutomataMCQ · 1 mark
Consider the following deterministic finite state automaton MM. Let SS denote the set of seven bit binary strings in which the first, the fourth, and the last bits are 11. The number of strings in SS that are accepted by MM is
Official PYQ2003Computer Organization and ArchitectureMachine Instructions and Addressing ModesMCQ · 1 mark
Consider the following assembly language program for a hypothetical processor A,B,A, B, and CC are 8−8-bit registers. The meanings of various instructions are shown as comments. …
Official PYQ2003Digital LogicComputer ArithmeticMCQ · 1 mark
Consider the ALU shown below. If the operands are in 2’s2’s complement representation, which of the following operations can be performed by suitably setting the control lines KK and C0C_0 only (+ and – denote addition and subtraction respectively)?