Sie sind auf Seite 1von 2

Suyash

Nande Homework-9 Algorithm and Data Structure

Answer 1

To write the greedy algorithm, we will assume the following:

A tree (TR) having vertex and edges as (VR) and (ED) respectively, and the cover-set would be
(CS).

Step 1: Well assign the cover-set to me null i.e. CS=f
Step 2: When the vertex (VR) is also not equal to f, then start the loop
Step 3: Recognize an end-vertex(leaf-vertex) l
Step 4: Pinpoint the parent vertex of l, and store in a variable m i.e. m=parent(l)
Step 5: Identify all the cover-sets from parent vertex i.e. CS = CS {m}
Step 6: Those edges which are incident to parent vertex (m), should be removed.
Step 7: The value of cover-set should be returned

Now, using Depth-First-Search, every leaf can be discovered in O (n)-time.


Answer 2

We need to assume the following:

An undirected graph (GR) with Vertex (VR) and Edges (ED) and a cost-function (cf) on its edges.
Let, optimal Hamilton tour of G be (H).

Let us assume, cfmax = max{cf({a, b}}) : aVR, bVR, ab}

Let us assume that, GR(VR, ED) is the complete undirected graph and its cost-function be (cf)
on its edges., then

cf({a, b}) = cf({a, b}) + cfmax : : aVR, bVR, ab}

We know that, H is an optimal Hamilton tour of GR, as the weight of all the Hamilton cycle of
GR has be increased by |VR| cfmax in GR.

Also, we know that GR satisfies the triangle inequality:
Again assume that p,q,r be the vertices, and well prove that:

cf({p, q}) cf({p, r}) + cf({q, r})
cf({p, q})+cfmax cf({p, r}) + cfmax + cf({q, r}) + cfmax
cf({p, q}) cf({p, r}) + cf({q, r}) + cfmax
which is true since, cf({p, q}) cfmax

Suyash Nande Homework-9 Algorithm and Data Structure

Also, we need to keep in mind the second part of the question i.e. affecting the weight of an
optimal tour. Any optimal tour has i-edges, so the total cost for any tour would be ij, and as we
know that change in cost is same for every tour, so the set of optimal tours also remains the
same.

Now, why this doesnt contradict theorem 35.3, let us again assume the following:

C = cost of a solution to the transformed problem found by p-approximation
C* = cost of an optimal solution to the transformed problem
Hence,
C pC*

Now, when we transform back to the original problem,
cf = C-ij is the weight of the solution, and
cf* = C*-ij is the weight of the optimal solution

So, we can say that cf + ij p(cf* + ij), so that
cf p(cf*) + (p-1),

Hence, there is no contradiction as we dont have a constant approximation ratio since p>1.

Das könnte Ihnen auch gefallen