/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} 21E A vertex cover of a graph G=(V,E... [FREE SOLUTION] | 91影视

91影视

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 鈥榰鈥 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 91影视!

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

Consider the following game. A 鈥渄ealer鈥 produces a sequence s1sn of 鈥渃ards,鈥 face up, where each card si has a value vi. Then two players take turns picking a card from the sequence, but can only pick the first or the last card of the (remaining) sequence. The goal is to collect cards of largest total value. (For example, you can think of the cards as bills of different denominations.) Assume n is even. (a) Show a sequence of cards such that it is not optimal for the first player to start by picking up the available card of larger value. That is, the natural greedy strategy is suboptimal. (b) Give an O(n2) algorithm to compute an optimal strategy for the first player. Given the initial sequence, your algorithm should precompute in O(n2) time some information, and then the first player should be able to make each move optimally in O(1) time by looking up the precomputed information.

Mean and median. One of the most basic tasks in statistics is to summarize a set of observations x1,x2,,xnR by a single number. Two popular choices for this summary statistic are:

鈥 The median, which we鈥檒l call1

鈥 The mean, which we鈥檒l call2

(a) Show that the median is the value of that minimizes the function

i|xi-|

You can assume for simplicity that is odd. (Hint: Show that for any , the function decreases if you move either slightly to the left or slightly to the right.)

(b) Show that the mean is the value of that minimizes the function

i(xi-)2

One way to do this is by calculus. Another method is to prove that for any R,

i(xi-)2=i(xi-2)2+n(-2)2

Notice how the function for 2 penalizes points that are far from much more heavily than the function for 1 . Thus 2 tries much harder to be close to all the observations. This might sound like a good thing at some level, but it is statistically undesirable because just a few outliers can severely throw off the estimate of 2 . It is therefore sometimes said that 1 is a more robust estimator than 2 . Worse than either of them, however, is , the value of that minimizes the function

maxi|xi-|

(c) Show that can be computed in O(n) time (assuming the numbers are xismall enough that basic arithmetic operations on them take unit time).

Show that, if c is a positive real number, then g(n) = 1 + c + c2 + 路 路 路 + cn is:

(a) 螛(1) if c < 1.

(b) 螛(n) if c = 1.

(c) 螛(cn) if c > 1.

The moral: in big-螛 terms, the sum of a geometric series is simply the first term if the series is strictly decreasing, the last term if the series is strictly increasing, or the number of terms if the series is unchanging.

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.)

How long does the recursive multiplication algorithm (page 25) take to multiply an n -bit number by an m -bit number? Justify your answer.

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.