Algorithms questions — page 3 of 7

Q30

GATE CS 2021 CS-1Algorithm AnalysisMCQ2 marks−2/3 if wrong
Consider the following recurrence relation.
T(n)={T(n/2)+T(2n/5)+7nif n>01if n=0T(n) = \begin{cases} T(n/2) + T(2n/5) + 7n & \text{if } n > 0 \\ 1 & \text{if } n = 0 \end{cases}
Which one of the following options is correct?
Show answer without attempting

Answer: C

Q40

GATE CS 2021 CS-1Algorithm DesignMSQ2 marks
Define RnR_n to be the maximum amount earned by cutting a rod of length nn meters into one or more pieces of integer length and selling them. For i > 0, let p[i] denote the selling price of a rod whose length is i meters. Consider the array of prices:
p[1] = 1, p[2] = 5, p[3] = 8, p[4] = 9, p[5] = 10, p[6] = 17, p[7] = 18
Which of the following statements is/are correct about R7R_7?
More than one option can be correct.
Show answer without attempting

Answer: A, C

Q41

GATE CS 2021 CS-1Graph AlgorithmsMSQ2 marks
An articulation point in a connected graph is a vertex such that removing the vertex and its incident edges disconnects the graph into two or more connected components.
Let TT be a DFS tree obtained by doing DFS in a connected undirected graph GG.
Which of the following options is/are correct?
More than one option can be correct.
Show answer without attempting

Answer: B

Q47

GATE CS 2021 CS-1Searching Sorting and HashingMSQ2 marks
Consider a dynamic hashing approach for 4-bit integer keys:
1. There is a main hash table of size 4.
2. The 2 least significant bits of a key is used to index into the main hash table.
3. Initially, the main hash table entries are empty.
4. Thereafter, when more keys are hashed into it, to resolve collisions, the set of all keys corresponding to a main hash table entry is organized as a binary tree that grows on demand.
5. First, the 3rd least significant bit is used to divide the keys into left and right subtrees.
6. To resolve more collisions, each node of the binary tree is further sub-divided into left and right subtrees based on the 4th least significant bit.
7. A split is done only if it is needed, i.e., only when there is a collision.
Consider the following state of the hash table.
Which of the following sequences of key insertions can cause the above state of the hash table (assume the keys are in decimal notation)?
Question figure
More than one option can be correct.
Show answer without attempting

Answer: C

Q1

GATE CS 2021 CS-2Graph AlgorithmsMCQ1 mark−1/3 if wrong
Let GG be a connected undirected weighted graph. Consider the following two statements.

S1S_1: There exists a minimum weight edge in GG which is present in every minimum spanning tree of GG.
S2S_2: If every edge in GG has distinct weight, then GG has a unique minimum spanning tree.

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

Answer: C

Q8

GATE CS 2021 CS-2Algorithm AnalysisMCQ1 mark−1/3 if wrong
What is the worst-case number of arithmetic operations performed by recursive binary search on a sorted array of size nn?
Show answer without attempting

Answer: B

Q26

GATE CS 2021 CS-2Algorithm DesignMCQ2 marks−2/3 if wrong
Consider the string abbccddeee. Each letter in the string must be assigned a binary code satisfying the following properties:
1. For any two letters, the code assigned to one letter must not be a prefix of the code assigned to the other letter.
2. For any two letters of the same frequency, the letter which occurs earlier in the dictionary order is assigned a code whose length is at most the length of the code assigned to the other letter.
Among the set of all binary code assignments which satisfy the above two properties, what is the minimum length of the encoded string?
Show answer without attempting

Answer: B

Q39

GATE CS 2021 CS-2Algorithm AnalysisMCQ2 marks−2/3 if wrong
For constants a≥1a \ge 1 and b>1b > 1, consider the following recurrence defined on the non-negative integers:

T(n)=a⋅T(nb)+f(n)T(n) = a \cdot T\left(\frac{n}{b}\right) + f(n)

Which of the following options is correct about the recurrence T(n)T(n)?
Show answer without attempting

Answer: C

Q46

GATE CS 2021 CS-2Graph AlgorithmsMSQ2 marks
Consider the following directed graph:

Which of the following is/are correct about the graph?
Question figure
More than one option can be correct.
Show answer without attempting

Answer: A, B

Q55

GATE CS 2021 CS-2Graph AlgorithmsNAT2 marks
In a directed acyclic graph with a source vertex ss, the quality-score of a directed path is defined to be the product of the weights of the edges on the path. Further, for a vertex vv other than ss, the quality-score of vv is defined to be the maximum among the quality-scores of all the paths from ss to vv. The quality-score of ss is assumed to be 1.

The sum of the quality-scores of all the vertices in the graph shown above is ____________.
Question figure
Show answer without attempting

Answer: 929

Q2

GATE CS 2020 CSAlgorithm AnalysisMCQ1 mark−1/3 if wrong
For parameters aa and bb, both of which are ω(1)\omega(1), T(n)=T(n1/a)+1T(n) = T(n^{1/a}) + 1, and T(b)=1T(b) = 1.

Then T(n)T(n) is
Show answer without attempting

Answer: A

Q6

GATE CS 2020 CSAlgorithm AnalysisMCQ1 mark−1/3 if wrong
What is the worst case time complexity of inserting n2n^2 elements into an AVL-tree with nn elements initially?
Show answer without attempting

Answer: C

Q23

GATE CS 2020 CSSearching Sorting and HashingNAT1 mark
Consider a double hashing scheme in which the primary hash function is h1(k)=k mod 23h_1(k) = k \bmod 23, and the secondary hash function is h2(k)=1+(k mod 19)h_2(k) = 1 + (k \bmod 19). Assume that the table size is 23. Then the address returned by probe 1 in the probe sequence (assume that the probe sequence begins at probe 0) for key value k=90k = 90 is __________.
Show answer without attempting

Answer: 13

Q31

GATE CS 2020 CSGraph AlgorithmsMCQ2 marks−2/3 if wrong
Let G=(V,E)G = (V, E) be a weighted undirected graph and let TT be a Minimum Spanning Tree (MST) of GG maintained using adjacency lists. Suppose a new weighted edge (u,v)∈V×V(u, v) \in V \times V is added to GG. The worst case time complexity of determining if TT is still an MST of the resultant graph is
Show answer without attempting

Answer: D

Q40

GATE CS 2020 CSGraph AlgorithmsMCQ2 marks−2/3 if wrong
Let G=(V,E)G = (V, E) be a directed, weighted graph with weight function w:E→Rw: E \rightarrow \mathbb{R}. For some function f:V→Rf: V \rightarrow \mathbb{R}, for each edge (u,v)∈E(u, v) \in E, define w′(u,v)w'(u, v) as w(u,v)+f(u)−f(v)w(u, v) + f(u) - f(v).

Which one of the options completes the following sentence so that it is TRUE?

“The shortest paths in GG under ww are shortest paths under w′w' too, __________.”
Show answer without attempting

Answer: A

Q49

GATE CS 2020 CSGraph AlgorithmsNAT2 marks
Consider a graph G=(V,E)G = (V, E), where V={v1,v2,…,v100}V = \{v_1, v_2, \ldots, v_{100}\}, E={(vi,vj)∣1≤i<j≤100}E = \{(v_i, v_j) \mid 1 \le i < j \le 100\}, and weight of the edge (vi,vj)(v_i, v_j) is ∣i−j∣|i - j|. The weight of minimum spanning tree of GG is __________.
Show answer without attempting

Answer: 99

Q20

GATE CS 2019 CSAlgorithm DesignNAT1 mark
An array of 25 distinct elements is to be sorted using quicksort. Assume that the pivot element is chosen uniformly at random. The probability that the pivot element gets placed in the worst possible location in the first round of partitioning (rounded off to 2 decimal places) is __________.
Show answer without attempting

Answer: 0.08

Q25

GATE CS 2019 CSAlgorithm DesignNAT1 mark
Consider a sequence of 14 elements: A=[−5,−10,6,3,−1,−2,13,4,−9,−1,4,12,−3,0]A = [-5, -10, 6, 3, -1, -2, 13, 4, -9, -1, 4, 12, -3, 0].
The subsequence sum S(i,j)=∑k=ijA[k]S(i, j) = \sum_{k=i}^j A[k]. Determine the maximum of S(i,j)S(i, j), where 0≤i≤j<140 \le i \le j < 14. (Divide and conquer approach may be used.)

Answer: __________.
Show answer without attempting

Answer: 29

Q37

GATE CS 2019 CSSearching Sorting and HashingMCQ2 marks−2/3 if wrong
There are nn unsorted arrays: A1,A2,...,AnA_1, A_2, ..., A_n. Assume that nn is odd. Each of A1,A2,...,AnA_1, A_2, ..., A_n contains nn distinct elements. There are no common elements between any two arrays. The worst-case time complexity of computing the median of the medians of A1,A2,...,AnA_1, A_2, ..., A_n is
Show answer without attempting

Answer: C

Q38

GATE CS 2019 CSGraph AlgorithmsMCQ2 marks−2/3 if wrong
Let GG be any connected, weighted, undirected graph.

I. GG has a unique minimum spanning tree, if no two edges of GG have the same weight.
II. GG has a unique minimum spanning tree, if, for every cut of GG, there is a unique minimum-weight edge crossing the cut.

Which of the above two statements is/are TRUE?
Show answer without attempting

Answer: C

0/200 correct0 marks

Related topics in GATE CS