retagged by
628 views
0 votes
0 votes

What is T.C. to find maximum number of edges to be added to a tree so that it stays as a bipartite graph?


Now my question is, why do we need to add  edges to make a tree bipartite? A tree is already bipartite graph. Right?? Again how do we add edges in it?? Is BFS or DFS do any improvement in such a tree?? How to think such a question??

retagged by

1 Answer

Best answer
3 votes
3 votes
Since it is a tree, choose any arbitrary node as root. Apply BFS at the root.Alternatively color the nodes at each level with red and black color.

Max edges=No.of red nodes $\times$ No. of black nodes - no.of edges in the tree.

You can do it in $O(n)$. Since it is a tree , there will be n-1 edges, if there are n vertices.
selected by

Related questions

3 votes
3 votes
2 answers
1
iarnav asked Apr 21, 2018
752 views
Please give some example regarding number of edges in dense graph is - |E| < |V2|I get that when we take log both sides we get O(ElogV), but I can't get this |E| < |V2|
0 votes
0 votes
1 answer
3
gate_forum asked Dec 25, 2015
1,103 views
minimum running time of algo that determines universal sink in a directed graph G={V,E} - a vertex with indegree |V|-1 and outdegree 0, given an adjacency matrix for G is...
0 votes
0 votes
2 answers
4
radha gogia asked Aug 5, 2015
2,170 views
Does it tale constant time or the time taken proportional to search in the entire partition of elements to find whether the component lies in that same component or not ?...