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
In a directed acyclic graph with a source vertex , the of a directed path is defined to be the product of the weights of the edges on the path. Further, for a vertex other than , the quality-score of is defined to be the maximum among the quality-scores of all the paths from to …
For parameters and , both of which are , , and . Then is
Consider a double hashing scheme in which the primary hash function is , and the secondary hash function is . Assume that the table size is . Then the address returned by probe in the probe sequence (assume that the probe sequence begins at probe ) for key value …
Let be a weighted undirected graph and let be a Minimum Spanning Tree (MST) of maintained using adjacency lists. Suppose a new weighed edge is added to . The worst case time complexity of determining if is still an MST of the resultant graph is
Let be a directed, weighted graph with weight function . For some function , for each edge, define as . Which one of the options completes the following sentence so that it is TRUE? “The shortest paths in under are shortest …
Consider the following C functions. int tob (int b, int* arr) { int i; for (i = 0; b>0; i++) { if (b%2) arr [i] = 1; else arr[i] = 0; b = b/2; } return (i); } int pp(int a, int b) { int arr[20]; int i, tot = 1, ex, len; ex = a; len = tob(b, arr); for (i=0; i<len ; i++) { if (arr[i] ==1) tot = tot * ex; ex= ex*ex; } return (tot) ; } The value returned …
Consider a graph , where , , and weight of the edge is . The weight of minimum spanning tree of is _________
An array of distinct elements is to be sorted using quicksort. Assume that the pivot element is chosen uniformly at random. The probability that the pivot element gets placed in the worst possible location in the first round of partitioning (rounded off to decimal places) is ________
Consider a sequence of elements: . The sequence sum . Determine the maximum of , where . (Divide and conquer approach may be used.) Answer: ___________
Consider the following C function. void convert (int n ) { if (n<0) printf{“%d”, n); else { convert(n/2); printf(“%d”, n%2); } } Which one of the following will happen when the function convert is called with any positive integer as argument?
There are unsorted arrays: . Assume that is odd.Each of contains distinct elements. There are no common elements between any two arrays. The worst-case time complexity of computing the median of the medians of is
Consider the weights and values of items listed below. Note that there is only one unit of each item. …
Consider the following undirected graph : Choose a value for that will maximize the number of minimum weight spanning trees (MWSTs) of . The number of MWSTs of for this value of is ____.
Consider the following program written in pseudo-code. Assume that and are integers. Count (x, y) { if (y !=1 ) { if (x !=1) { print("*"); Count (x/2, y); } else { y=y-1; Count (1024, y); } } } The number of times that the statement is executed by the call is _____
Let be a graph with vertices, with each vertex labelled by a distinct permutation of the numbers There is an edge between vertices and if and only if the label of can be obtained by swapping two adjacent numbers in the label of . Let denote the degree of a vertex in , and denote the …
Let be a simple undirected graph. Let be a depth first search tree of . Let be a breadth first search tree of . Consider the following statements. No edge of is a cross edge with respect to . (A cross edge in is between two nodes neither of which is an ancestor of the other in ). For every edge …
Assume that multiplying a matrix of dimension with another matrix of dimension requires scalar multiplications. Computing the product of matrices can be done by parenthesizing in different ways. Define as an explicitly computed pair for a given …
Consider the following table: …
Consider the following functions from positive integers to real numbers: , , , , . The CORRECT arrangement of the above functions in increasing order of asymptotic complexity is:
Let be an array of numbers consisting of a sequence of 's followed by a sequence of 's. The problem is to find the smallest index such that is by probing the minimum number of locations in . The worst case number of probes performed by an optimal algorithm is ____________.
