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
Let be connected, undirected, edge-weighted graph. The weights of the edges in are positive and distinct. Consider the following statements: Minimum Spanning Tree of is always unique. Shortest path between any two vertices of is always unique. Which of the above statements is/are necessarily true?
Consider the recurrence function Then in terms of notation is
A message is made up entirely of characters from the set . The table of probabilities for each of the characters is shown below: …
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 in terms of notation is
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?
Match the algorithms with their time complexities: …
is an undirected simple graph in which each edge has a distinct weight, and is a particular edge of . Which of the following statements about the minimum spanning trees of is/are TRUE? If is the lightest edge of some cycle in , then every MST of includes . If is the heaviest edge of some …
Let be a complete undirected graph on vertices, having edges with weights being and . The maximum possible weight that a minimum weight spanning tree of can have is __________
Let 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? : Minimum spanning tree of does not change. : Shortest path between any pair of vertices does not change.
Consider the following directed graph: The number of different topological orderings of the vertices of the graph is _____________.
The worst case running times of Insertion sort , Merge sort and Quick sort, respectively are:
In an adjacency list representation of an undirected simple graph , each edge has two adjacency list entries: in the adjacency list of , and in the adjacency list of . These are called twins of each other. A twin pointer is a pointer from an adjacency list entry to its twin. If and , and the …
Let and be four matrices of dimensions and , respectively. The minimum number of scalar multiplications required to find the product using the basic matrix multiplication method is _________.
The given diagram shows the flowchart for a recursive function . Assume that all statements, except for the recursive calls, have time complexity. If the worst case time complexity of this function is , then the least possible value (accurate up to two decimal positions) of is ________. Flow chart for Recursive …
The Floyd-Warshall algorithm for all-pair shortest paths computation is based on
Breadth First Search (BFS) is started on a binary tree beginning from the root vertex. There is a vertex at a distance four from the root. If is the vertex in this BFS traversal, then the maximum possible value of is __________
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 time Bubblesort runs in time Mergesort runs in time Insertion sort runs in time
Let a represent the number of bit strings of length n containing two consecutive s. What is the recurrence relation for ?
Let be a simple undirected graph, and be a particular vertex in it called the source. For , let denote the shortest distance in from to . A breadth first search (BFS) is performed starting at . Let be the resultant BFS tree. If is an edge of that is not in , then which …
The graph shown below has edges with distinct integer edge weights. The minimum spanning tree (MST) is of weight and contains the edges: . 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 edges of this …
