Algorithms questions

Q17

GATE CS 2026 CS-1Algorithm AnalysisMCQ1 mark−1/3 if wrong
Consider the following recurrence relations:
For all n>1n > 1,
T1(n)=4T1(n2)+T2(n)T_1(n) = 4T_1\left(\frac{n}{2}\right) + T_2(n)
T2(n)=5T2(n4)+Θ(log⁡2n)T_2(n) = 5T_2\left(\frac{n}{4}\right) + \Theta(\log_2 n)

Assume that for all n≤1n \le 1, T1(n)=1T_1(n) = 1 and T2(n)=1T_2(n) = 1.
Which one of the following options is correct?
Show answer without attempting

Answer: A

Q24

GATE CS 2026 CS-1Searching Sorting and HashingMSQ1 mark
Consider a hash table P[0,1,…,10]P[0, 1, \dots, 10] that is initially empty. The hash table is maintained using open addressing with linear probing. The hash function used is
h(x)=(x+7)(mod11)h(x) = (x + 7) \pmod{11}.

Consider the following sequence of insertions performed on PP:
1,13,22,15,11,241, 13, 22, 15, 11, 24

Which of the following positions in the hash table is/are empty after these insertions are performed?
More than one option can be correct.
Show answer without attempting

Answer: C

Q41

GATE CS 2026 CS-1Graph AlgorithmsMCQ2 marks−2/3 if wrong
Let G(V,E)G(V, E) 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 s∈Vs \in V be a vertex in GG. For every u∈Vu \in V and for every k≥0k \ge 0, let dk(u)d_k(u) denote the weight of a shortest path (in terms of weight) from ss to uu of length at most kk. If there is no path from ss to uu of length at most kk, then dk(u)=∞d_k(u) = \infty.

Consider the statements:
S1: For every k≥0k \ge 0 and u∈Vu \in V, dk+1(u)≤dk(u)d_{k+1}(u) \le d_k(u).
S2: For every (u,v)∈E(u, v) \in E, if (u,v)(u, v) is part of a shortest path (in terms of weight) from ss to vv, then for every k≥0k \ge 0, dk(u)≤dk(v)d_k(u) \le d_k(v).

Which one of the following options is correct?
Show answer without attempting

Answer: A

Q49

GATE CS 2026 CS-1Graph AlgorithmsMSQ2 marks
Let G(V,E)G(V, E) be a simple, undirected, edge-weighted graph with unique edge weights.

Which of the following statements about the minimum spanning trees (MST) of GG is/are true?
More than one option can be correct.
Show answer without attempting

Answer: A, D

Q50

GATE CS 2026 CS-1Graph AlgorithmsMSQ2 marks
Consider the following pseudocode for depth-first search (DFS) algorithm which takes a directed graph G(V,E)G(V, E) as input, where d[v]d[v] and f[v]f[v] are the discovery time and finishing time, respectively, of the vertex v∈Vv \in V.
DFS(G):
 unmark all v in V
 t <- 0
 for each v in V
 if v is unmarked
 t <- Explore(G, v, t)
 end if
 end for

Explore(G, v, t):
 mark v
 t <- t + 1
 d[v] <- t
 for each (v, w) in E
 if w is unmarked
 t <- Explore(G, w, t)
 end if
 end for
 t <- t + 1
 f[v] <- t
 return t
Suppose that the input directed graph G(V,E)G(V, E) is a directed acyclic graph (DAG).
For an edge (u,v)∈E(u, v) \in E, which of the following options will NEVER be correct?
More than one option can be correct.
Show answer without attempting

Answer: B, D

Q55

GATE CS 2026 CS-1Graph AlgorithmsMSQ2 marks
An undirected, unweighted, simple graph G(V,E)G(V, E) is said to be 2-colorable if there exists a function c:V→{0,1}c: V \to \{0, 1\} such that for every (u,v)∈E(u, v) \in E, c(u)≠c(v)c(u) \neq c(v).

Which of the following statements about 2-colorable graphs is/are true?
More than one option can be correct.
Show answer without attempting

Answer: B, C

Q24

GATE CS 2026 CS-2Algorithm AnalysisMCQ1 mark−1/3 if wrong
Consider the following functions, where nn is a positive integer.

n1/3,log⁡(n),log⁡(n!),2log⁡(n)n^{1/3}, \quad \log(n), \quad \log(n!), \quad 2^{\log(n)}

Which one of the following options lists the functions in increasing order of asymptotic growth rate?

Note: Assume the base of log to be 2.
Show answer without attempting

Answer: A

Q25

GATE CS 2026 CS-2Algorithm AnalysisMSQ1 mark
Which of the following can be recurrence relation(s) corresponding to an algorithm with time complexity Θ(n)\Theta(n)?
More than one option can be correct.
Show answer without attempting

Answer: A, B

Q30

GATE CS 2026 CS-2Searching Sorting and HashingNAT1 mark
The keys 5, 28, 19, 15, 26, 33, 12, 17, 10 are inserted into a hash table using the hash function h(k)=k mod 9h(k) = k \bmod 9. The collisions are resolved by chaining. After all the keys are inserted, the length of the longest chain is __________. (answer in integer)
Show answer without attempting

Answer: 3

Q32

GATE CS 2026 CS-2Searching Sorting and HashingNAT1 mark
Consider an array A=[10,7,8,19,41,35,25,31]A = [10, 7, 8, 19, 41, 35, 25, 31]. Suppose the merge sort algorithm is executed on array AA to sort it in increasing order. The merge sort algorithm will carry out a total of 7 merge operations.

A merge operation on sorted left array LL and sorted right array RR is said to be void if the output of the merge operation is the elements of array LL followed by the elements of array RR.

The number of void merge operations among these 7 merge operations is __________. (answer in integer)
Show answer without attempting

Answer: 3

Q37

GATE CS 2026 CS-2Graph AlgorithmsMCQ2 marks−2/3 if wrong
Let GG be a weighted directed acyclic graph with mm edges and nn vertices. Given GG and a source vertex ss in GG, which one of the following options gives the worst case time complexity of the fastest algorithm to find the lengths of shortest paths from ss to all vertices that are reachable from ss in GG?
Show answer without attempting

Answer: A

Q38

GATE CS 2026 CS-2Algorithm AnalysisMCQ2 marks−2/3 if wrong
Consider an array AA of integers of size nn. The indices of AA run from 1 to nn. An algorithm is to be designed to check whether AA satisfies the condition given below.

∀i,j∈{1,…,n−1}\forall i, j \in \{1, \dots, n - 1\} such that i>ji > j, (A[i+1]−A[i])>(A[j+1]−A[j])(A[i + 1] - A[i]) > (A[j + 1] - A[j])

Which one of the following gives the worst case time complexity of the fastest algorithm that can be designed for the problem?
Show answer without attempting

Answer: A

Q39

GATE CS 2026 CS-2Algorithm DesignMCQ2 marks−2/3 if wrong
Consider a table TT, where the elements T[i][j],0≤i,j≤nT[i][j], 0 \le i, j \le n, 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:

T[0][k]=T[k][0]=1for k=0,1,2,…,nT[0][k] = T[k][0] = 1 \quad \text{for } k = 0,1,2, \dots, n

T[i][j]=2T[i−1][j]+3T[i][j−1]for 1≤i,j≤nT[i][j] = 2T[i - 1][j] + 3T[i][j - 1] \quad \text{for } 1 \le i, j \le n

Consider the following two algorithms to compute entries of TT. Assume that for both the algorithms, for all 0≤i,j≤n0 \le i, j \le n, T[i][j]T[i][j] has been initialized to 1.

Algorithm B1B_1:
For i = 1, 2, ..., n
 For j = 1, 2, ..., n
 T[i][j] = 2T[i - 1][j] + 3T[i][j - 1]
Algorithm B2B_2:
For s = 2, 3, ..., 2n
 For i = 1, 2, ..., n
 For j = 1, 2, ..., n
 If (i + j == s)
 T[i][j] = 2T[i - 1][j] + 3T[i][j - 1]
Algorithm Bk,k∈{1,2}B_k, k \in \{1,2\} is said to be correct if and only if it calculates the correct values of T[i][j]T[i][j], for all 0≤i,j≤n0 \le i, j \le n, (as per the recursive formulation) at the end of the execution of the algorithm BkB_k.

Which one of the following statements is true?
Show answer without attempting

Answer: A

0/130 correct0 marks

Related topics in GATE CS