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
Consider the following recurrence relations: For all , Assume that for all and . Which one of the following options is correct?
Let be an odd number greater than . Consider a binary minheap with elements stored in an array whose index starts from . Which of the following indices of do/does NOT correspond to any leaf node of the minheap?
Consider a hash table that is initially empty. The hash table is maintained using open addressing with linear probing. The hash function used is . Consider the following sequence of insertions performed on : Which of the following positions in the hash table is/are empty …
The height of a binary tree is the number of edges in the longest path from the root to a leaf in the tree. The maximum possible height of a full binary tree with nodes is .(answer in integer)
Let be the set of all integers from to . Consider any order of insertion of the elements of into a binary search tree that creates a complete binary tree. Which one of the following elements can NEVER be the third element that is inserted?
Let be an undirected, edge-weighted graph with integer weights. The weight of a path is the sum of the weights of the edges in that path. The length of a path is the number of edges in that path. Let be a vertex in . For every and for every , let denote the weight of a shortest path (in terms …
Let be a simple, undirected, edge-weighted graph with unique edge weights. Which of the following statements about the minimum spanning trees (MST) of is/are true?
Consider the following pseudocode for depth-first search (DFS) algorithm which takes a directed graph as input, where and are the discovery time and finishing time, respectively, of the vertex . …
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 returns is . (answer in integer) Note: Ignore …
The following sequence corresponds to the preorder traversal of a binary search tree : The position of the element in the postorder traversal of is . (answer in integer) Note: The position begins with .
Consider the following functions, where is a positive integer. Which one of the following options lists the functions in increasing order of asymptotic growth rate? Note: Assume the base of log to be .
Which of the following can be recurrence relation(s) corresponding to an algorithm with time complexity ?
The keys are inserted into a hash table using the hash function . The collisions are resolved by chaining. After all the keys are inserted, the length of the longest chain is . (answer in integer)
Consider an array . Suppose the merge sort algorithm is executed on array to sort it in increasing order. The merge sort algorithm will carry out a total of merge operations. A merge operation on sorted left array and sorted right array is said to be void if the output of the merge operation is the …
Let be a weighted directed acyclic graph with edges and vertices. Given and a source vertex in , which one of the following options gives the worst case time complexity of the fastest algorithm to find the lengths of shortest paths from to all vertices that are reachable from in
Consider an array of integers of size . The indices of run from to . An algorithm is to be designed to check whether satisfies the condition given below. such that Which one of the following gives the worst case time complexity of the fastest …
Consider a table , where the elements , represent the cost of the optimal solutions of different subproblems of a problem that is being solved using a dynamic programming algorithm. The recursive formulation to compute the table entries is as follows: …
Consider a binary search tree (BST) with leaf nodes . Given any node , the key present in the node is denoted as . All the keys present in the given BST are distinct. The keys belong to the set of real numbers. For a node , let denote the node that is its inorder successor. If a …
Let be any undirected graph with positive edge weights, and be a minimum spanning tree of . For any two vertices, and , let and be the shortest distances between and in and , respectively. Which ONE of the options is CORRECT for all possible and ?
Consider the following recurrence relation: Which ONE of the following options is CORRECT?
