# Algorithm

 Question 1
For constants $a\geq 1$ and $b \gt 1$, consider the following recurrence defined on the non-negative integers:

$T(n) = a \cdot T \left(\dfrac{n}{b} \right) + f(n)$

Which one of the following options is correct about the recurrence $T(n)$?
 A if $f(n)$ is $n \log_2(n)$, then $T(n)$ is $\Theta(n \log_2(n))$. B if $f(n)$ is $\dfrac{n}{\log_2(n)}$, then $T(n)$ is $\Theta(\log_2(n))$. C if $f(n)$ is $O(n^{\log_b(a)-\epsilon})$ for some $\epsilon \gt 0$, then $T(n)$ is $\Theta(n ^{\log_b(a)})$. D if $f(n)$ is $\Theta(n ^{\log_b(a)})$, then $T(n)$ is $\Theta(n ^{\log_b(a)})$.
GATE CSE 2021 SET-2      Recurrence Relation
Question 1 Explanation:
 Question 2
Consider the string abbccddeee. Each letter in the string must be assigned a binary code satisfying the following properties:

For any two letters, the code assigned to one letter must not be a prefix of the code assigned to the other letter.
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?
 A 21 B 23 C 25 D 30
GATE CSE 2021 SET-2      Greedy Technique
Question 2 Explanation:
 Question 3
Let G be a connected undirected weighted graph. Consider the following two statements.

S1: There exists a minimum weight edge in G which is present in every minimum spanning tree of G.
S2: If every edge in G has distinct weight, then G has a unique minimum spanning tree.

Which one of the following options is correct?
 A Both S1 and S2 are true B S1 is true and S2 is false C S1 is false and S2 is true D Both S1 and S2 are false
GATE CSE 2021 SET-2      Minimum Spanning Tree
Question 3 Explanation:
 Question 4
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 T be a DFS tree obtained by doing DFS in a connected undirected graph G.
Which of the following options is/are correct?
 A Root of T can never be an articulation point in G. B Root of T is an articulation point in G if and only if it has 2 or more children. C A leaf of T can be an articulation point in G. D If u is an articulation point in G such that x is an ancestor of u in T and y is a descendent of u in T, then all paths from x to y in G must pass through u.
GATE CSE 2021 SET-1      Graph Traversal
Question 4 Explanation:
 Question 5
Define $R_n$ to be the maximum amount earned by cutting a rod of length n 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:

$\text{p}=1,\text{p}=5,\text{p}=8,\text{p}=9,\text{p}=10,\text{p}=17,\text{p}=18$

which of the following statements is/are correct about $R_7$?
[MSQ]
 A $R_7=18$ B $R_7=19$ C $R_7$ is achieved by three different solutions. D $R_7$ cannot be achieved by a solution consisting of three pieces.
GATE CSE 2021 SET-1      Greedy Technique
Question 5 Explanation:
 Question 6
Let $G=(V,E)$ be an undirected unweighted connected graph. The diameter of $G$ is defined as:
$diam(G)=\displaystyle \max_{u,v \in V} \{ \text{the length of shortest path between }u \text{ and }v \}$

Let $M$ be the adjacency matrix of $G$.
Define graph $G_2$ on the same set of vertices with adjacency matrix $N$, where

$N_{ij}=\left\{\begin{array} {lcl} 1 &\text{if}\; M_{ij}>0 \text{ or } P_{ij}>0, \text{ where }P=M^2\\0 &\text{otherwise} \end{array}\right.$

Which one of the following statements is true?
 A $diam(G_2)\leq \left \lceil diam(G)/2 \right \rceil$ B $\left \lceil diam(G)/2 \right \rceil \lt diam(G_2) \lt diam(G)$ C $diam(G_2) =diam(G)$ D $diam(G) \lt diam(G_2) \leq 2 \; diam(G)$
GATE CSE 2021 SET-1      Shortest Path
Question 6 Explanation:
 Question 7
Consider the following recurrence relation.
$T\left ( n \right )=\left\{\begin{array} {lcl} T(n/2)+T(2n/5)+7n & \text{if} \; n > 0\\1 & \text{if}\; n=0 \end{array}\right.$
Which one of the following options is correct?
 A $T(n)=\Theta (n^{5/2})$ B $T(n)=\Theta (n \log n)$ C $T(n)=\Theta (n)$ D $T(n)=\Theta ((\log n)^{5/2})$
GATE CSE 2021 SET-1      Recurrence Relation
Question 7 Explanation:
 Question 8
Consider the following undirected graph with edge weights as shown: The number of minimum-weight spanning trees of the graph is __________
 A 4 B 6 C 5 D 3
GATE CSE 2021 SET-1      Minimum Spanning Tree
Question 8 Explanation:
 Question 9
Consider the following array.

$\begin{array}{|l|l|l|l|l|l|l|l|} \hline 23&32&45&69&72&73&89&97 \\ \hline\end{array}$

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?
 A Selection sort B Mergesort C Insertion sort D Quicksort using the last element as pivot
GATE CSE 2021 SET-1      Sorting
Question 9 Explanation:
 Question 10
Consider the following three functions.

$f_1=10^n\; f_2=n^{\log n}\;f_3=n^{\sqrt {n}}$

Which one of the following options arranges the functions in the increasing order of asymptotic growth rate?
 A $f_3, f_2, f_1$ B $f_2, f_1, f_3$ C $f_1, f_2, f_3$ D $f_2, f_3, f_1$
GATE CSE 2021 SET-1      Asymptotic Notation
Question 10 Explanation:

There are 10 questions to complete. 