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 PYQ2015AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
An algorithm performs (log⁡N)12(\log N)^{\frac{1}{2}} find operations , NN insert operations, (log⁡N)12(\log N)^{\frac{1}{2}} delete operations, and (log⁡N)12(\log N)^{\frac{1}{2}} decrease-key operations on a set of data items with keys drawn from a linearly ordered set . For a delete operation, a pointer is provided to the record that must be deleted . For the …
Official PYQ2015AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Consider the following C function. int fun1 (int n) { int i, j, k, p, q = 0; for (i = 1; i < n; ++i) { p = 0; for (j = n; j > 1; j = j/2) ++p; for (k = 1; k < p; k = k * 2) ++q; } return q; } Which one of the following most closely approximates the return value of the function fun1\text{fun1}?
Official PYQ2015AlgorithmsAlgorithm Design: Greedy TechniquesMCQ · 1 mark
Match the following: …
Official PYQ2015AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Which one of the following is the recurrence equation for the worst case time complexity of the quick sort algorithm for sorting n  (≥2)n\;( \geq 2) numbers? In the recurrence equations given in the options below, cc is a constant.
Official PYQ2015AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Suppose you are provided with the following function declaration in the C programming language. int partition(int a[], int n); The function treats the first element of a[ ]a[\:] as a pivot and rearranges the array so that all elements less than or equal to the pivot is in the left part of the array, and all elements greater than the pivot is in the right …
Official PYQ2015AlgorithmsAlgorithm Design: Greedy TechniquesMCQ · 1 mark
Given below are some algorithms, and some algorithm design paradigms. …
Official PYQ2015AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
An unordered list contains nn distinct elements. The number of comparisons to find an element in this list that is neither maximum nor minimum is
Official PYQ2015AlgorithmsAsymptotic Worst Case Time and Space ComplexityNAT · 1 mark
Consider the following C function. int fun(int n) { int x=1, k; if (n==1) return x; for (k=1; k<n; ++k) x = x + fun(k) * fun (n-k); return x; } The return value of fun(5)fun(5) is ______.
Official PYQ2015AlgorithmsAsymptotic Worst Case Time and Space ComplexityNAT · 1 mark
Suppose c=⟨c[0],…,c[k−1]⟩c = \langle c[0], \dots, c[k-1]\rangle is an array of length kk, where all the entries are from the set {0,1}\{0, 1\}. For any positive integers a and na \text{ and } n, consider the following pseudocode. DOSOMETHING (c, a, n) z ← 1 for i ← 0 to k-1 do z ← z² mod n if c[i]=1 then z ← (z × a) mod n return z If …
Official PYQ2015AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Let f(n)=nf(n) = n and g(n)=n(1+sin⁡ n)g(n) = n^{(1 + \sin \: n)}, where nn is a positive integer. Which of the following statements is/are correct? f(n)=O(g(n))f(n) = O(g(n)) f(n)=Ω(g(n))f(n) = \Omega(g(n))
Official PYQ2015AlgorithmsMinimum Spanning TreesNAT · 1 mark
Let GG be a connected undirected graph of 100100 vertices and 300300 edges. The weight of a minimum spanning tree of GG is 500500. When the weight of each edge of GG is increased by five, the weight of a minimum spanning tree becomes ______.
Official PYQ2015AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Consider the following recursive C function. void get(int n) { if (n<1) return; get (n-1); get (n-3); printf("%d", n); } If get(6)get(6) function is being called in main()main() then how many times will the get()get() function be invoked before returning to the main()main()?
Official PYQ2015AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Assume that a mergesort algorithm in the worst case takes 3030 seconds for an input of size 6464. Which of the following most closely approximates the maximum input size of a problem that can be solved in 66 minutes?
Official PYQ2015AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Consider the equality ∑i=0ni3=X\displaystyle{\sum_{i=0}^n} i^3 = X and the following choices for XX: Θ(n4)\Theta(n^4) Θ(n5)\Theta(n^5) O(n5)O(n^5) Ω(n3)\Omega(n^3) The equality above remains correct if XX is replaced by
Official PYQ2014AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Consider the following pseudo code. What is the total number of multiplications to be performed? D = 2 for i = 1 to n do for j = i to n do for k = j + 1 to n do D = D * 3
Official PYQ2014AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Consider the following C function in which size is the number of elements in the array E: int MyX(int *E, unsigned int size) { int Y = 0; int Z; int i, j, k; for(i = 0; i< size; i++) Y = Y + E[i]; for(i=0; i < size; i++) for(j = i; j < size; j++) { Z = 0; for(k = i; k <= j; k++) Z = Z + E[k]; if(Z > Y) Y = Z; } return Y; } The value returned …
Official PYQ2014AlgorithmsSearching, Sorting, HashingNAT · 1 mark
The minimum number of comparisons required to find the minimum and the maximum of 100100 numbers is ________
Official PYQ2014AlgorithmsAlgorithm Design: Greedy TechniquesNAT · 1 mark
There are 55 bags labeled 11 to 55. All the coins in a given bag have the same weight. Some bags have coins of weight 1010 gm, others have coins of weight 1111 gm. I pick 1,2,4,8,161, 2, 4, 8, 16 coins respectively from bags 11 to 55 Their total weight comes out to 323323 gm. Then the product of the labels of the bags having 1111 gm coins is …
Official PYQ2014AlgorithmsGraph Traversals (BFS, DFS)MCQ · 1 mark
Consider the directed graph below given. Which one of the following is TRUE?
Official PYQ2014AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Let PP be quicksort program to sort numbers in ascending order using the first element as the pivot. Let t1t_1 and t2t_2 be the number of comparisons made by P for the inputs [1 2 3 4 5][1 \ 2 \ 3 \ 4 \ 5] and [4 1 5 3 2][4 \ 1 \ 5 \ 3 \ 2] respectively. Which one of the following holds?