Greedy Method · Algorithms · GATE CSE

Start Practice

Marks 1

Marks 2

1

Let $G$ be an undirected connected graph in which every edge has a positive integer weight. Suppose that every spanning tree in $G$ has even weight. Which of the following statements is/are TRUE for every such graph $G$?

GATE CSE 2024 Set 2
2

The number of distinct minimum-weight spanning trees of the following graph is ________

GATE CSE 2024 Set 2 Algorithms - Greedy Method Question 1 English

GATE CSE 2024 Set 2
3

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? 

GATE CSE 2021 Set 2
4
Let G = (V, E) be a weighted undirected graph and let T be a Minimum Spanning Tree (MST) of G maintained using adjacency lists. Suppose a new weighted edge (u, v) $$ \in $$ V $$ \times $$ V is added to G. The worst case time complexity of determining if T is still an MST of the resultant graph is
GATE CSE 2020
5
Consider a graph G = (V, E), where V = {v1, v2, ...., v100},
E = {(vi, vj) | 1 ≤ i < j ≤ 100}, and weight of the edge (vi, vj) is |i - j|. The weight of the minimum spanning tree of G is ______.
GATE CSE 2020
6
Consider the weights and values of items listed below. Note that there is only one unit of each item.

Item number Weight
(in Kgs)
Value
(in Rupees)
1 10 60
2 7 28
3 4 20
4 2 24

The task is to pick a subset of these items such that their total weight is no more than $$11$$ $$Kgs$$ and their total value is maximized. Moreover, no item may be split. The total value of items picked by an optimal algorithm is denoted by $$V$$opt. A greedy algorithm sorts the items by their value-to-weight ratios in descending order and packs them greedily, starting from the first item in the ordered list. The total value of items picked by the greedy algorithm is denoted by $$V$$greedy.

The value of $$V$$opt $$−$$ $$V$$greedy is ____________.

GATE CSE 2018
7

Consider the following undirected graph $$G: $$

GATE CSE 2018 Algorithms - Greedy Method Question 8 English

Choose a value for $$x$$ that will maximize the number of minimum weight spanning trees $$(MWSTs)$$ of $$G.$$ The number of $$MWSTs$$ of $$G$$ for this value of $$x$$ is ______.

GATE CSE 2018
8
$$G = (V,E)$$ is an undirected simple graph in which each edge has a distinct weight, and e is a particular edge of G. Which of the following statements about the minimum spanning trees $$(MSTs)$$ of $$G$$ is/are TRUE?

$$\,\,\,\,\,\,\,\,\,\,{\rm I}.\,\,\,\,\,\,\,\,\,\,$$ If $$e$$ is the lightest edge of some cycle in $$G,$$ then every $$MST$$ of $$G$$
$$\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,$$includes $$e$$
$$\,\,\,\,\,\,\,\,{\rm I}{\rm I}.\,\,\,\,\,\,\,\,\,\,$$ If $$e$$ is the heaviest edge of some cycle in $$G,$$ then every $$MST$$ of $$G$$
$$\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,$$excludes $$e$$

GATE CSE 2016 Set 1
9
Consider the weighted undirected graph with $$4$$ vertices, where the weight of edge $$\left\{ {i,j} \right\}$$ is given by the entry $${W_{ij}}$$ in the matrix $$W.$$ $$$W = \left[ {\matrix{ 0 & 2 & 8 & 5 \cr 2 & 0 & 5 & 8 \cr 8 & 5 & 0 & X \cr 5 & 8 & X & 0 \cr } } \right]$$$

The largest possible integer value of $$x,$$ for which at least one shortest path between some pair of vertices will contain the edge with weight $$x$$ is _________________.

GATE CSE 2016 Set 1
10
The graph shown below has 8 edges with distinct integer edge weights. The minimum spanning tree (MST) is of weight 36 and contains the edges: {(A, C), (B, C), (B, E), (E, F), (D, F)}. The edge weights of only those edges which are in the MST are given in the figure shown below. The minimum possible sum of weights of all 8 edges of this graph is ___________. GATE CSE 2015 Set 1 Algorithms - Greedy Method Question 13 English
GATE CSE 2015 Set 1
11
A Young tableau is a $$2D$$ array of integers increasing from left to right and from top to bottom. Any unfilled entries are marked with $$\infty ,$$ and hence there cannot be any entry to the right of, or below a $$\infty .$$ The following Young tableau consists of unique entries.

1 2 5 14
3 4 6 23
10 12 18 25
31

When an element is removed from a Young tableau, other elements should be moved into its place so that the resulting table is still a Young tableau (unfilled entries may be filled in with a $$\infty $$). The minimum number of entries (other than $$1$$) to be shifted, to remove $$1$$ from the given Young tableau is ______________.

GATE CSE 2015 Set 2
12
Suppose P, Q, R, S, T are sorted sequences having lengths 20, 24, 30, 35, 50 respectively. They are to be merged into a single sequence by merging together two sequences at a time. The number of comparisons that will be needed in the worst case by the optimal algorithm for doing this is ____.
GATE CSE 2014 Set 2
13
The number of distinct minimum spanning trees for the weighted graph below is ________ GATE CSE 2014 Set 2 Algorithms - Greedy Method Question 15 English
GATE CSE 2014 Set 2
14
Consider the directed graph shown in the figure below. There are multiple shortest paths between vertices S and T. Which one will be reported by Dijkstra’s shortest path algorithm? Assume that, in any iteration, the shortest path to a vertex v is updated only when a strictly shorter path to v is discovered. GATE CSE 2012 Algorithms - Greedy Method Question 18 English
GATE CSE 2012
15
An undirected graph G(V, E) contains n ( n > 2 ) nodes named v1 , v2 ,….vn. Two nodes vi , vj are connected if and only if 0 < |i – j| <= 2. Each edge (vi, vj ) is assigned a weight i + j. A sample graph with n = 4 is shown below. GATE CSE 2011 Algorithms - Greedy Method Question 20 English What will be the cost of the minimum spanning tree (MST) of such a graph with n nodes?
GATE CSE 2011
16
An undirected graph G(V, E) contains n ( n > 2 ) nodes named v1 , v2 ,….vn. Two nodes vi , vj are connected if and only if 0 < |i – j| <= 2. Each edge (vi, vj ) is assigned a weight i + j. A sample graph with n = 4 is shown below. GATE CSE 2011 Algorithms - Greedy Method Question 19 English The length of the path from v5 to v6 in the MST of previous question with n = 10 is
GATE CSE 2011
17
Consider a complete undirected graph with vertex set {0, 1, 2, 3, 4}. Entry W(ij) in the matrix W below is the weight of the edge {i, j}. $$$w = \left( {\matrix{ 0 & 1 & 8 & 1 & 4 \cr 1 & 0 & {12} & 4 & 9 \cr 8 & {12} & 0 & 7 & 3 \cr 1 & 4 & 7 & 0 & 2 \cr 4 & 9 & 3 & 2 & 0 \cr } } \right)$$$ What is the minimum possible weight of a spanning tree T in this graph such that vertex 0 is a leaf node in the tree T?
GATE CSE 2010
18
Consider a complete undirected graph with vertex set {0, 1, 2, 3, 4}. Entry W(ij) in the matrix W below is the weight of the edge {i, j}. $$$w = \left( {\matrix{ 0 & 1 & 8 & 1 & 4 \cr 1 & 0 & {12} & 4 & 9 \cr 8 & {12} & 0 & 7 & 3 \cr 1 & 4 & 7 & 0 & 2 \cr 4 & 9 & 3 & 2 & 0 \cr } } \right)$$$ What is the minimum possible weight of a path P from vertex 1 to vertex 2 in this graph such that P contains at most 3 edges?
GATE CSE 2010
19
Consider the following graph: GATE CSE 2009 Algorithms - Greedy Method Question 24 EnglishWhich one of the following is NOT the sequence of edges added to the minimum spanning tree using Kruskal’s algorithm?
GATE CSE 2009
20
GATE CSE 2008 Algorithms - Greedy Method Question 25 English Dijkstra's single source shortest path algorithm when run from vertex a in the above graph, computes the correct shortest path distance to
GATE CSE 2008
21
Let w be the minimum weight among all edge weights in an undirected connected graph. Let e be a specific edge of weight w . Which of the following is FALSE?
GATE CSE 2007
22
Suppose the letters a, b, c, d, e, f have probabilities 1/2, 1/4, 1/8, 1/16, 1/32, 1/32 respectively. What is the average length of Huffman codes?
GATE CSE 2007
23
In an unweighted, undirected connected graph, the shortest path from a node S to every other node is computed most efficiently, in terms of time complexity by
GATE CSE 2007
24
Suppose the letters a, b, c, d, e, f have probabilities 1/2, 1/4, 1/8, 1/16, 1/32, 1/32 respectively. Which of the following is the Huffman code for the letter a, b, c, d, e, f?
GATE CSE 2007
25
Consider the following graph: GATE CSE 2006 Algorithms - Greedy Method Question 29 English Which one of the following cannot be the sequence of edges added, in that order, to a minimum spanning tree using Kruskal’s algorithm?
GATE CSE 2006
26
Suppose we run Dijkstra’s single source shortest-path algorithm on the following edge-weighted directed graph with vertex P as the source.
GATE CSE 2004 Algorithms - Greedy Method Question 30 English In what order do the nodes get included into the set of vertices for which the shortest path distances are finalized?
GATE CSE 2004
27
Let G=(V,E) be an undirected graph with a subgraph G1=(V1,E1). Weights are assigned to edges of G as follows. $$$w(e) = \begin{cases} 0 \text{, if } e \in E_1 \\1 \text{, otherwise} \end{cases}$$$ A single-source shortest path algorithm is executed on the weighted graph (V,E,w) with an arbitrary vertex v1 of V1 as the source. Which of the following can always be inferred from the path costs computed?
GATE CSE 2003
28
Let G = (V, E) be a directed graph with n vertices. A path from vi to vj in G is sequence of vertices (vi, vi+1, ……., vj) such that (vk, vk+1) ∈ E for all k in i through j – 1. A simple path is a path in which no vertex appears more than once. Let A be an n x n array initialized as follow
$$$A[j,k] = \left\{ {\matrix{ {1\,if\,(j,\,k)} \cr {1\,otherwise} \cr } } \right.$$$ Consider the following algorithm.
for i = 1 to n
   for j = 1 to n
      for k = 1 to n
         A [j , k] = max (A[j, k] (A[j, i] + A [i, k]); 
Which of the following statements is necessarily true for all j and k after terminal of the above algorithm ?
GATE CSE 2003
29
What is the weight of a minimum spanning tree of the following graph? GATE CSE 2003 Algorithms - Greedy Method Question 14 English
GATE CSE 2003
30
Let G be an undirected connected graph with distinct edge weight. Let emax be the edge with maximum weight and emin the edge with minimum weight. Which of the following statements is false?
GATE CSE 2000
31
Complexity of Kruskal’s algorithm for finding the minimum spanning tree of an undirected graph containing n vertices and m edges if the edges are sorted is _______.
GATE CSE 1992
32
The weighted external path length of the binary tree in figure is ___________. GATE CSE 1991 Algorithms - Greedy Method Question 16 English
GATE CSE 1991
33
Kruskal’s algorithm for finding a minimum spanning tree of a weighted graph G with n vertices and m edges has the time complexity of:
GATE CSE 1991
EXAM MAP
Medical
NEETAIIMS
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
Civil Services
UPSC Civil Service
Defence
NDA
Staff Selection Commission
SSC CGL Tier I
CBSE
Class 12