A vertex cover of a graph G=(V,E)is a subset of vertices SVthat includes at least one endpoint of every edge in E. Give a linear-time algorithm for the following task.

Input: An undirected tree T=(V,E).

Output: The size of the smallest vertex cover of T. For instance, in the following tree, possible vertex covers include{A,B,C,D,E,F,G}and{A,C,D,F}but not{C,E,F}.The smallest vertex cover has size 3: {B,E,G}.

Short Answer

Expert verified

The recursion will run in linear time that is On.

Step by step solution

01

Defining Recurrence relation

We have given a graphG=V,E where we have to find the smallest vertex cover. Vertex cover is a set of vertices that includes at least one endpoint of every edge of the graph. In order to find the size of smallest vertex cover of the given graph, we will use dynamic programming approach where we will find out all possible vertex cover of all subproblems and then select that vertex cover which is smallest.

vi=minj:jChildi1+k:kChildjvk,1+j:jChildivj

02

Solution.

Let us suppose that for each node ‘(u)’ in the graph, we considerVuas the size of minimum vertex cover for a subtree which is rooted at node ‘u’.

Fig: A undirected graph.

Vertex cover is a set of vertices that includes at least one endpoint of every edge of the graph. In order to find the size of smallest vertex cover of the given graph, we will use dynamic programming approach where we will find out all possible vertex cover of all subproblems and then select that vertex cover which is smallest.

Our base condition will be when our node ‘u’ is leaf node. In this case, Vu=0. This is because we cannot obtain subtree from leaf node.

For any internal node of a subtree, we have:

vi=minj:jChildi1+k:kChildjvk,1+j:jChildivj

On solving the above recursive equation, we will get output as Vr, where r is the root of the tree. Thus,Vris the size of the minimum vertex cover. The algorithm according to the above stated recursion relation, solve all the subproblem in order of decreasing depth of the tree.

This recursion will run in linear time that is On.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

The kSPANNING TREE problem is the following.Input: An undirected graph G=(V,E) Output: A spanning tree of G in which each node has degree k, if such a tree exists.Show that for any k2:

  1. k SPANNING TREE is a search problem.
  2. k SPANNING TREE is NP-complete. (Hint: Start with k=2 and consider the relation between this problem and RUDRATA PATH.)

The Fibonacci numbers F0,F1,F2,... are defined by the rule

F0=0,F1=1,Fn=Fn1+Fn2.

In this problem we will confirm that this sequence grows exponentially fast and obtain some bounds on its growth.

(a) Use induction to prove that Fn20.5nfor n6.

(b) Find a constant c<1such thatFn2cn for all n0. Show that your answer is correct.

(c) What is the largestc you can find for which Fn=Ω(2cn)?

There are many variants of Rudrata’s problem, depending on whether the graph is undirected or directed, and whether a cycle or path is sought. Reduce the DIRECTED RUDRATA PATH problem to each of the following.(a)The (undirected) RUDRATA PATH problem.(b) The undirected RUDRATA PATH problem, which is just like RUDRATA PATH except that the endpoints of the path are specified in the input.

The tramp steamer problem. You are the owner of a steamship that can apply between a group of port cities V . You make money at each port: a visit to city i earns you a profit of pi dollars. Meanwhile, the transportation cost from port i to port j is cij>0 .You want to find a cyclic route in which the ratio of profit to cost is maximized.

To this end, consider a directed graph G=(V,E) whose nodes are ports, and which has edges between each pair of ports. For any cycle C in this graph, the profit-to-cost ratio is

role="math" localid="1658920675878" r(c)=i,jicPiji,jicCij

Let r' be the maximum ratio achievable by a simple cycle. One way to determine r' is by binary search: by first guessing some ratio r , and then testing whether it is too large or too small. Consider any positive r>0 . Give each edge (i,j) a weight of wij=rcij-pj .

  1. Show that if there is a cycle of negative weight, then .
  2. Show that if all cycles in the graph have strictly positive weight, then r<r*.
  3. Give an efficient algorithm that takes as input a desired accuracy >0 and returns a simple cycle c for which r(C)3r*- Justify the correctness of your algorithm and analyze its running time in terms of |V|, and R=max(i,j)iE(PJCIJ) .

Question: 0.1. In each of the following situations, indicate whether f=O(g),orf=Ω(g),or both (in which case f=(g))

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free