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 PYQ2000AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Consider the following functions f(n)=3nnf(n) = 3n^{\sqrt{n}} g(n)=2nlog⁡2ng(n) = 2^{\sqrt{n}{\log_{2}n}} h(n)=n!h(n) = n! Which of the following is true?
Official PYQ2000AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Suppose you are given an array s[1....n]s[1....n] and a procedure reverse (s,i,j)(s, i, j) which reverses the order of elements in ss between positions ii and jj (both inclusive). What does the following sequence do, where 1⩽k⩽n1 \leqslant k \leqslant n: reverse (s, 1, k); reverse (s, k+1, n); reverse (s, 1, n);
Official PYQ2000AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Let SS be a sorted array of nn integers. Let T(n)T(n) denote the time taken for the most efficient algorithm to determined if there are two elements with sum less than 10001000 in SS. Which of the following statement is true?
Official PYQ2000AlgorithmsGraph Traversals (BFS, DFS)MCQ · 1 mark
The most appropriate matching for the following pairs X: depth first search1: heap Y: breadth first search2: queueZ: sorting3: stack\begin{array}{|l|l|}\hline \text{X: depth first search} & \text{1: heap } \\ \hline \text{Y: breadth first search} & \text{2: queue} \\ \hline \text{Z: sorting} & \text{3: stack} \\ \hline \end{array} is:
Official PYQ1999AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Consider the following CC function definition int Trial (int a, int b, int c) { if ((a>=b) && (c<b)) return b; else if (a>=b) return Trial(a, c, b); else return Trial(b, a, c); } The functional Trial:
Official PYQ1999AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
If T1=O(1)T_1 = O(1), give the correct matching for the following pairs: …
Official PYQ1999AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
If nn is a power of 22, then the minimum number of multiplications needed to compute ana^n is
Official PYQ1999AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
If one uses straight two-way merge sort algorithm to sort the following elements in ascending order: 20, 47, 15, 8, 9, 4, 40, 30, 12, 1720, \ 47, \ 15, \ 8, \ 9, \ 4, \ 40, \ 30, \ 12, \ 17 then the order of these elements after second pass of the algorithm is:
Official PYQ1999AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Suppose we want to arrange the nn numbers stored in any array such that all negative values occur before all positive ones. Minimum number of exchanges required in the worst case is
Official PYQ1999AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
A sorting technique is called stable if
Official PYQ1999AlgorithmsAlgorithm Design: Greedy TechniquesMCQ · 1 mark
The minimum number of record movements required to merge five files A (with 1010 records), B (with 2020 records), C (with 1515 records), D (with 55 records) and E (with 2525 records) is:
Official PYQ1998AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
What value would the following function return for the input x=95x=95? Function fun (x:integer):integer; Begin If x > 100 then fun = x – 10 Else fun = fun(fun (x+11)) End;
Official PYQ1998AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Which one of the following algorithm design techniques is used in finding all pairs of shortest distances in a graph?
Official PYQ1998AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Give the correct matching for the following pairs: …
Official PYQ1997AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Let T(n)T(n) be the function defined by T(1)=1, T(n)=2T(⌊n2⌋)+nT(1) =1, \: T(n) = 2T (\lfloor \frac{n}{2} \rfloor ) + \sqrt{n} for n≥2n \geq 2. Which of the following statements is true?
Official PYQ1997AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
The correct matching for the following pairs is …
Official PYQ1996AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
Quick-sort is run on two inputs shown below to sort in ascending order taking first element as pivot 1,2,3,…n1, 2, 3, \dots n n,n−1,n−2,…,2,1n, n-1, n-2, \dots, 2, 1 Let C1C_1 and C2C_2 be the number of comparisons made for the inputs (i) and (ii) respectively. Then,
Official PYQ1996AlgorithmsSearching, Sorting, HashingMCQ · 1 mark
The average number of key comparisons required for a successful search for sequential search on nn items is
Official PYQ1996AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
The recurrence relation T(1)=2T(1) = 2 T(n)=3T(n4)+nT(n) = 3T (\frac{n}{4}) +n has the solution T(n)T(n) equal to
Official PYQ1996AlgorithmsAsymptotic Worst Case Time and Space ComplexityMCQ · 1 mark
Which of the following is false?