Algorithms questions

Q2

GATE CS 2021 CS-1Searching Sorting and HashingMCQ1 mark−1/3 if wrong
Let P be an array containing nn integers. Let tt be the lowest upper bound on the number of comparisons of the array elements, required to find the minimum and maximum values in an arbitrary array of nn elements. Which one of the following choices is correct?
Show answer without attempting

Answer: C

Q3

GATE CS 2021 CS-1Algorithm AnalysisMCQ1 mark−1/3 if wrong
Consider the following three functions.
f1=10nf2=nlog⁡nf3=nnf_1 = 10^n \qquad f_2 = n^{\log n} \qquad f_3 = n^{\sqrt{n}}
Which one of the following options arranges the functions in the increasing order of asymptotic growth rate?
Show answer without attempting

Answer: D

Q9

GATE CS 2021 CS-1Searching Sorting and HashingMCQ1 mark−1/3 if wrong
Consider the following array.
2332456972738997
Which algorithm out of the following options uses the least number of comparisons (among the array elements) to sort the above array in ascending order?
Show answer without attempting

Answer: C

Q17

GATE CS 2021 CS-1Graph AlgorithmsNAT1 mark
Consider the following undirected graph with edge weights as shown:
The number of minimum-weight spanning trees of the graph is ______.
Question figure
Show answer without attempting

Answer: 3

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

0/140 correct0 marks

Related topics in GATE CS