retagged by
2,483 views

2 Answers

4 votes
4 votes
Given, a forest has 100 vertices and 40 edges.

A tree with 100 vertices has 99 edges.

To convert a forest into a tree, number of edges that should be added = (Number of components - 1)

Let number of components be $x$

$\therefore$  40 + ($x$ - 1) = 99

$x$ = 60
0 votes
0 votes
The number of connected components in G is same as number of connected components in the forest generated by DFS traversal.

A forest with 100 vertices and 0 edges has 100 components.

Adding 1 edge will reduce the number of components by 1, as an additional edge will connect 2 components. Remember the resulting graph has to be a forest, it cannot have any cycle, i.e. we can only add the edge between vertices that belong to different components.

Repeatedly adding 1 edge 40 times, results in reduction of number of components by 1, 40 times. That means we will end up with 100 - 40 = 60 connected components.

Answer - 60
Answer:

Related questions

4.0k
views
2 answers
5 votes
Arjun asked Feb 16
4,006 views
Let $G$ be a directed graph and $T$ a depth first search $\text{(DFS)}$ spanning tree in $G$ that is rooted at a vertex $v$. Suppose $T$ is also a breadth ... $G$ with respect to the tree $T$The only edges in $G$ are the edges in $T$
13.6k
views
8 answers
50 votes
Akash Kanase asked Feb 12, 2016
13,579 views
Breadth First Search (BFS) is started on a binary tree beginning from the root vertex. There is a vertex $t$ at a distance four from the root. If $t$ ... $n$ is __________
17.7k
views
4 answers
44 votes
go_editor asked Sep 28, 2014
17,717 views
Suppose depth first search is executed on the graph below starting at some unknown vertex. Assume that a recursive call to visit a vertex is made only ... Then the maximum possible recursion depth (including the initial call) is _________.
18.9k
views
10 answers
51 votes
makhdoom ghaya asked Feb 13, 2015
18,947 views
Let $G = (V, E)$ be a simple undirected graph, and $s$ be a particular vertex in it called the source. For $x \in V$, let $d(x)$ denote the shortest distance in $G$ ... $?$-1$0$1$2$