# Algorithm

 Question 1
Let $G(V, E)$ be a directed graph, where $V = \{1, 2, 3, 4, 5 \}$ is the set of vertices and $E$ is the set of directed edges, as defined by the following adjacency matrix $A$.
$A[i][j]= \left \{ \begin{matrix} 1 &1 \leq j \leq i \leq 5 \\ 0& otherwise \end{matrix} \right.$
$A[i][j]=1$indicates a directed edge from node $i$ to node $j$. A directed spanning tree of $G$, rooted at $r \in V$ , is defined as a subgraph $T$ of $G$ such that the undirected version of $T$ is a tree, and $T$ contains a directed path from $r$ to every other vertex in $V$. The number of such directed spanning trees rooted at vertex 5 is ____
 A 24 B 36 C 12 D 6
GATE CSE 2022      Minimum Spanning Tree
Question 1 Explanation:
 Question 2
Consider a simple undirected weighted graph G, all of whose edge weights are distinct. Which of the following statements about the minimum spanning trees of G is/are TRUE?
MSQ
 A The edge with the second smallest weight is always part of any minimum spanning tree of G . B One or both of the edges with the third smallest and the fourth smallest weights are part of any minimum spanning tree of G . C Suppose $S\subseteq V$ be such that $S\neq \phi$ and $S\neq V$ . Consider the edge with the minimum weight such that one of its vertices is in S and the other in V \ S . Such an edge will always be part of any minimum spanning tree of G . D G can have multiple minimum spanning trees.
GATE CSE 2022      Minimum Spanning Tree
Question 2 Explanation:
 Question 3
Which one of the following statements is TRUE for all positive functions $f(n)$?
 A $f(n^2)=\theta (f(n)^2)$, where $f(n)$ is a polynomial B $f(n^2)=o (f(n)^2)$ C $f(n^2)=O (f(n)^2)$, where $f(n)$ is an exponential function D $f(n^2)=\Omega (f(n)^2)$
GATE CSE 2022      Asymptotic Notation
Question 3 Explanation:
 Question 4
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 4 Explanation:
 Question 5
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 5 Explanation:
 Question 6
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 6 Explanation:
 Question 7
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 7 Explanation:
 Question 8
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]=1,\text{p}[2]=5,\text{p}[3]=8,\text{p}[4]=9,\text{p}[5]=10,\text{p}[6]=17,\text{p}[7]=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 8 Explanation:
 Question 9
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 9 Explanation:
 Question 10
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 10 Explanation:

There are 10 questions to complete.

### 2 thoughts on “Algorithm”

1. UPDATE THE QUES NO. 33
CORRECT ANS X=5;