Algorithms questions

Q18

GATE CS 2025 CS-1Graph AlgorithmsMCQ1 mark−1/3 if wrong
Let GG be any undirected graph with positive edge weights, and TT be a minimum spanning tree of GG. For any two vertices, uu and vv, let d1(u,v)d_1(u, v) and d2(u,v)d_2(u, v) be the shortest distances between uu and vv in GG and TT, respectively. Which ONE of the options is CORRECT for all possible G,T,uG, T, u and vv?
Show answer without attempting

Answer: B

Q20

GATE CS 2025 CS-1Algorithm AnalysisMCQ1 mark−1/3 if wrong
Consider the following recurrence relation:
T(n)=2T(n−1)+n2nT(n) = 2T(n - 1) + n2^n for n>0n > 0, T(0)=1T(0) = 1.
Which ONE of the options is CORRECT?
Show answer without attempting

Answer: A

Q33

GATE CS 2025 CS-1Searching Sorting and HashingNAT1 mark
The pseudocode of a function fun() is given below:
fun(int A[0,\dots,n-1]){
 for i=0 to n-2
 for j=0 to n-i-2
 if (A[j]>A[j+1])
 then swap A[j] and A[j+1]
}
Let A[0,…,29]A[0, \dots, 29] be an array storing 30 distinct integers in descending order. The number of swap operations that will be performed, if the function fun() is called with A[0,…,29]A[0, \dots, 29] as argument, is __________. (Answer in integer)
Show answer without attempting

Answer: 435

Q43

GATE CS 2025 CS-1Graph AlgorithmsMCQ2 marks−2/3 if wrong
Let G(V,E)G(V, E) be an undirected and unweighted graph with 100 vertices. Let d(u,v)d(u, v) denote the number of edges in a shortest path between vertices uu and vv in VV. Let the maximum value of d(u,v)d(u, v), u,v∈Vu, v \in V such that u≠vu \neq v, be 30. Let TT be any breadth-first-search tree of GG. Which ONE of the given options is CORRECT for every such graph GG?
Show answer without attempting

Answer: C

Q64

GATE CS 2025 CS-1Graph AlgorithmsNAT2 marks
The maximum value of xx such that the edge between the nodes B and C is included in every minimum spanning tree of the given graph is _________ . (answer in integer)
Question figure
Show answer without attempting

Answer: 5

Q65

GATE CS 2025 CS-1Searching Sorting and HashingNAT2 marks
In a double hashing scheme, h1(k)=k mod 11h_1(k) = k \bmod 11 and h2(k)=1+(k mod 7)h_2(k) = 1 + (k \bmod 7) are the auxiliary hash functions. The size mm of the hash table is 11. The hash function for the i-th probe in the open address table is [h1(k)+i h2(k)] mod m[h_1(k) + i \, h_2(k)] \bmod m. The following keys are inserted in the given order: 63, 50, 25, 79, 67, 24.
The slot at which key 24 gets stored is ___________. (Answer in integer)
Show answer without attempting

Answer: 10 to 11

Q20

GATE CS 2025 CS-2Searching Sorting and HashingMCQ1 mark−1/3 if wrong
Consider an unordered list of NN distinct integers.

What is the minimum number of element comparisons required to find an integer in the list that is NOT the largest in the list?
Show answer without attempting

Answer: A

Q29

GATE CS 2025 CS-2Graph AlgorithmsMSQ1 mark
Which of the following statements regarding Breadth First Search (BFS) and Depth First Search (DFS) on an undirected simple graph G is/are TRUE?
More than one option can be correct.
Show answer without attempting

Answer: B, C, D

Q37

GATE CS 2025 CS-2Graph AlgorithmsMCQ2 marks−2/3 if wrong
Let GG be an edge-weighted undirected graph with positive edge weights. Suppose a positive constant α\alpha is added to the weight of every edge.

Which ONE of the following statements is TRUE about the minimum spanning trees (MSTs) and shortest paths (SPs) in GG before and after the edge weight update?
Show answer without attempting

Answer: C

Q41

GATE CS 2025 CS-2Algorithm AnalysisMCQ2 marks−2/3 if wrong
An array AA of length nn with distinct elements is said to be bitonic if there is an index 1≤i≤n1 \le i \le n such that A[1…i]A[1 \dots i] is sorted in the non-decreasing order and A[i+1…n]A[i+1 \dots n] is sorted in the non-increasing order.

Which ONE of the following represents the best possible asymptotic bound for the worst-case number of comparisons by an algorithm that searches for an element in a bitonic array AA?
Show answer without attempting

Answer: D

Q59

GATE CS 2025 CS-2Graph AlgorithmsNAT2 marks
Consider the following algorithm someAlgo that takes an undirected graph GG as input.

someAlgo(GG)
1. Let vv be any vertex in GG. Run BFS on GG starting at vv. Let uu be a vertex in GG at maximum distance from vv as given by the BFS.
2. Run BFS on GG again with uu as the starting vertex. Let zz be the vertex at maximum distance from uu as given by the BFS.
3. Output the distance between uu and zz in GG.

The output of someAlgo(TT) for the tree shown in the given figure is ___________. (Answer in integer)
Question figure
Show answer without attempting

Answer: 6

0/110 correct0 marks

Related topics in GATE CS