GATE 2026 Algorithms PYQs | Time and Space Complexity

Last Updated :
Discuss
Comments

Question 1

The given diagram shows the flowchart for a recursive function A(n). Assume that all statements, except for the recursive calls, have O(1) time complexity. If the worst-case time complexity of this function is O(nα ), then the least possible value (accurate up to two decimal positions) of α is _____.


fdkjs
Flowchart for Recursive Function A(n)


GATE CSE 2016,SET1 - [2Marks] (NAT)

Question 2

[Tex]\begin{aligned} &\text{Consider the following functions, where } n \text{ is a positive integer.} \\ &\quad n^{1/3},\ \log n,\ \log(n!),\ 2^{\log n} \\ &\text{Which one of the following options lists the functions in increasing order of asymptotic growth} \\ &\text{rate? Note: Assume the base of } \log \text{ to be 2.} \end{aligned}[/Tex]

[GATE 2026 || SET-2 MCQ || 1-mark]

  • [Tex]\log n,\ n^{1/3},\ 2^{\log n},\ \log(n!)[/Tex]

  • [Tex]n^{1/3},\ \log n,\ \log(n!),\ 2^{\log n}[/Tex]

  • [Tex]\log n,\ n^{1/3},\ \log(n!),\ 2^{\log n}[/Tex]

  • [Tex]\log n,\ n^{1/3},\ \log(n!),\ 2^{\log n}[/Tex]

Question 3

Which of the following can be recurrence relation(s) corresponding to an algorithm with time complexity O(n)? [GATE 2026 || SET-2 MSQ || 1-mark]

  • [Tex]T(n) = T(n-1) + 1, \quad T(1) = 1[/Tex]

  • [Tex]T(n) = 2T(n/2) + 1, \quad T(1) = 1[/Tex]

  • [Tex]T(n) = 2T(n/2) + n, \quad T(1) = 1[/Tex]

  • [Tex]T(n) = T(n-1) + n, \quad T(1) = 1[/Tex]

Question 4

[Tex]\begin{aligned} &\textbf{Consider the following recurrence relations:} \\ &\text{For all } n > 1, \\ &\quad T_1(n) = 4T_1(n/2) + T_2(n) \\ &\quad T_2(n) = 5T_2(n/4) + \Theta(\log_2 n) \\ &\text{Assume that for all } n \le 1,\ T_1(n) = 1 \text{ and } T_2(n) = 1. \\ &\textbf{Which one of the following options is correct?} \end{aligned}[/Tex]

[GATE 2026 || SET-1 MCQ || 1-mark]

  • [Tex]T_1(n) = \Theta(n^2)[/Tex]

  • [Tex]T_1(n) = \Theta(n^2 \log_2 n)[/Tex]

  • [Tex]T_1(n) = \Theta\left(n^{\log_4 5}\right)[/Tex]

  • [Tex]T_1(n) = \Theta\left(n^{\log_4 5} \cdot \log_2 n\right)[/Tex]

Question 5

Consider the following recurrence relation:

T(n)=2T(n−1)+n.2n for n>0, T(0)=1

Which ONE of the following options is CORRECT?
GATE CSE 2025,SET1 - [2Marks] (MCQ)

  • T(n)=Θ(n22n)

  • T(n)=Θ(n2n)

  • T(n)=Θ((logn)22n)

  • T(n)=Θ(4n)

Question 6

A meld operation on two instances of a data structure combines them into one single instance of the same data structure. Consider the following data structures:

P: Unsorted doubly linked list with pointers to the head node and tail node of the list.

Q: Min-heap implemented using an array.

R: Binary Search Tree.

Which ONE of the following options gives the worst-case time complexities for meld operation on instances of size n of these data structures?
GATE CSE 2025,SET2 - [2Marks] (MCQ)


  • P: Θ(1), Q: Θ(n), R: Θ(n)

  • P: Θ(1), Q: Θ(nlogn), R: Θ(n)

  • P: Θ(n), Q: Θ(nlogn), R: Θ(n2)

  • P: Θ(1), Q: Θ(n), R: Θ(nlogn)

Question 7

Let T(n) be the recurrence relation defined as follows:
T(0) = 1,
T(1) = 2 and
T(n) = 5T(n − 1) − 6T(n − 2) for n ≥ 2
Which one of the following statement is TRUE?
GATE CSE 2024,SET2 - [1Marks] (MCQ)


  • T(n) = Θ(n·3ⁿ)

  • T(n) = Θ(n·2ⁿ)

  • T(n) = Θ(3ⁿ)

  • T(n) = Θ(2ⁿ)

Question 8

Consider the following recurrence relation:

[Tex]\begin{aligned} &T(n) = \begin{cases} \sqrt{n} \cdot T(\sqrt{n}) + n & \text{for } n \ge 1 \\ 1 & \text{for } n = 1 \end{cases} \end{aligned}[/Tex]

Which one of the following options is CORRECT?
GATE CSE 2024,SET1 - [2Marks] (MCQ)

  • T(n) = Θ(nloglogn)

  • T(n) = Θ(n2logn)

  • T(n) = Θ(nlogn)

  • T(n) = Θ(n2loglogn)

Question 9

Consider functions Function 1 and Function 2 expressed in pseudocode as follows:

Function 1 and Function 2

while n > 1 do

for i = 1 to n do

x = x + 1;

end for

n = ⌊n/2⌋;

end while

for i = 1 to 100 * n do

x = x + 1;

end for

Let f1(n) and f2(n) denote the number of times the statement x = x + 1; is executed in Function 1 and Function 2, respectively.
GATE CSE 2023,SET1 - [2Marks] (MSQ)

  • f1​(n) ∈ Θ(f2​(n))

  • f1​(n) ∈ o(f2​(n))

  • f2​(n) ∈ ω(f1​(n))

  • f1​(n) ∈ O(n)

Question 10

Given an integer array of size N, we want to check if the array is sorted (in either ascending or descending order). An algorithm solves this problem by making a single pass through the array and comparing each element of the array only with its adjacent elements. The worst-case time complexity of this algorithm is
GATE CSE 2024,SET1 - [1Marks] (MCQ)

  • both O(N)and Ω(N)

  • O(N) but not Ω(N)

  • Ω(N) but not O(N)

  • neither O(N) nor Ω(N)

Tags:

There are 31 questions to complete.

Take a part in the ongoing discussion