Skip to content

GATE CS Algorithms questions

Practise Algorithms questions for GATE CS. Explore official PYQs and original subject-wise quizzes, check answers and view available solutions. Free, no sign-in.

Compare greedy choices, dynamic-programming states and graph algorithms. Identify the input size before analysing the time and space complexity of each solution.

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 PYQ2017AlgorithmsGraph Traversals (BFS, DFS)MCQ · 1 mark
Let G=(V,E)G=\left ( V,E \right ) be anyany connected, undirected, edge-weighted graph. The weights of the edges in EE are positive and distinct. Consider the following statements: Minimum Spanning Tree of GG is always unique. Shortest path between any two vertices of GG is always unique. Which of the above statements is/are necessarily true?
Official PYQ2017AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Consider the recurrence function T(n)={2T(n)+1,n>22,0<n≤2T(n) = \begin{cases} 2T(\sqrt{n})+1, & n>2 \\ 2, & 0 < n \leq 2 \end{cases} Then T(n)T(n) in terms of Θ\Theta notation is
Official PYQ2017AlgorithmsAlgorithm Design: Greedy TechniquesNAT · 1 mark
A message is made up entirely of characters from the set X={P,Q,R,S,T}X=\{P, Q, R, S, T\}. The table of probabilities for each of the characters is shown below: …
Official PYQ2017AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Consider the following C function int fun(int n) { int i, j; for(i=1; i<=n; i++) { for (j=1; j<n; j+=i) { printf("%d %d", i, j); } } } Time complexity of funfun in terms of Θ\Theta notation is
Official PYQ2017AlgorithmsGraph Traversals (BFS, DFS)MCQ · 1 mark
The Breadth First Search (BFS) algorithm has been implemented using the queue data structure. Which one of the following is a possible order of visiting the nodes in the graph below?
Official PYQ2017AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Match the algorithms with their time complexities: …
Official PYQ2016AlgorithmsMinimum Spanning TreesMCQ · 1 mark
G=(V,E)G=(V, E) is an undirected simple graph in which each edge has a distinct weight, and ee is a particular edge of GG. Which of the following statements about the minimum spanning trees (MSTs)(MSTs) of GG is/are TRUE? If ee is the lightest edge of some cycle in GG, then every MST of GG includes ee. If ee is the heaviest edge of some …
Official PYQ2016AlgorithmsMinimum Spanning TreesNAT · 1 mark
Let GG be a complete undirected graph on 44 vertices, having 66 edges with weights being 1,2,3,4,5,1, 2, 3, 4, 5, and 66. The maximum possible weight that a minimum weight spanning tree of GG can have is __________
Official PYQ2016AlgorithmsMinimum Spanning TreesMCQ · 1 mark
Let GG be a weighted connected undirected graph with distinct positive edge weights. If every edge weight is increased by the same value, then which of the following statements is/are TRUE? PP: Minimum spanning tree of GG does not change. QQ: Shortest path between any pair of vertices does not change.
Official PYQ2016AlgorithmsGraph Traversals (BFS, DFS)NAT · 1 mark
Consider the following directed graph: The number of different topological orderings of the vertices of the graph is _____________.
Official PYQ2016AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
The worst case running times of Insertion sort , Merge sort and Quick sort, respectively are:
Official PYQ2016AlgorithmsGraph Traversals (BFS, DFS)MCQ · 1 mark
In an adjacency list representation of an undirected simple graph G=(V,E)G=(V, E), each edge (u,v)(u, v) has two adjacency list entries: [v][v] in the adjacency list of uu, and [u][u] in the adjacency list of vv. These are called twins of each other. A twin pointer is a pointer from an adjacency list entry to its twin. If ∣E∣=m|E|=m and ∣V∣=n|V|=n, and the …
Official PYQ2016AlgorithmsAlgorithm Design: Dynamic ProgrammingNAT · 1 mark
Let A1,A2,A3A_{1}, A_{2}, A_{3} and A4A_{4} be four matrices of dimensions 10×5,5×20,20×1010 \times 5, 5 \times 20, 20 \times 10 and 10×510 \times 5, respectively. The minimum number of scalar multiplications required to find the product A1A2A3A4A_{1}A_{2}A_{3}A_{4} using the basic matrix multiplication method is _________.
Official PYQ2016AlgorithmsAsymptotic Worst Case Time and Space ComplexityNAT · 1 mark
The given diagram shows the flowchart for a recursive function A(n)A(n). Assume that all statements, except for the recursive calls, have O(1)O(1) time complexity. If the worst case time complexity of this function is O(nα)O(n^{\alpha}), then the least possible value (accurate up to two decimal positions) of α\alpha is ________. Flow chart for Recursive …
Official PYQ2016AlgorithmsAlgorithm Design: Dynamic ProgrammingMCQ · 1 mark
The Floyd-Warshall algorithm for all-pair shortest paths computation is based on
Official PYQ2016AlgorithmsGraph Traversals (BFS, DFS)NAT · 1 mark
Breadth First Search (BFS) is started on a binary tree beginning from the root vertex. There is a vertex tt at a distance four from the root. If tt is the nthn^{\text{th}} vertex in this BFS traversal, then the maximum possible value of nn is __________
Official PYQ2016AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in the ascending order, which of the following are TRUE? Quicksort runs in Θ(n2)\Theta (n^2) time Bubblesort runs in Θ(n2)\Theta (n^2) time Mergesort runs in Θ(n)\Theta (n) time Insertion sort runs in Θ(n)\Theta (n) time
Official PYQ2015AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Let an_{n} represent the number of bit strings of length n containing two consecutive 11s. What is the recurrence relation for ana_{n}?
Official PYQ2015AlgorithmsGraph Traversals (BFS, DFS)MCQ · 1 mark
Let G=(V,E)G = (V, E) be a simple undirected graph, and ss be a particular vertex in it called the source. For x∈Vx \in V, let d(x)d(x) denote the shortest distance in GG from ss to xx. A breadth first search (BFS) is performed starting at ss. Let TT be the resultant BFS tree. If (u,v)(u, v) is an edge of GG that is not in TT, then which …
Official PYQ2015AlgorithmsMinimum Spanning TreesNAT · 1 mark
The graph shown below has 88 edges with distinct integer edge weights. The minimum spanning tree (MST) is of weight 3636 and contains the edges: {(A,C),(B,C),(B,E),(E,F),(D,F)}\{(A, C), (B, C), (B, E), (E, F), (D, F)\}. The edge weights of only those edges which are in the MST are given in the figure shown below. The minimum possible sum of weights of all 88 edges of this …