Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Sometimes we want light spanning trees with certain special properties. Here’s an example.

Input: Undirected graph G=(V,E) ; edge weights we; subset of vertices UV

Output: The lightest spanning tree in which the nodes of U are leaves (there might be other leaves in this tree as well).

(The answer isn’t necessarily a minimum spanning tree.)

Give an algorithm for this problem which runs in O(ElogV) time. (Hint: When you remove nodes Ufrom the optimal solution, what is left?)

Short Answer

Expert verified

Working with lightest spanning tree in the nodes of and to get answer which is necessary minimum spanning tree base on the given formulaO(|E|log|V|).

Step by step solution

01

Step 1: Light-spanning tree algorithm

Both lemma1 as well as feature 1 are being used in the light spanning tree algorithm..

Lemma1:• "If indeed the network has vertices "U" as leaves, a lightest spanning trees containing vertices "U" for leaves isn't really possible." G” There isn't a minimal spanning tree."

Property 1:

• “"Minimal level spanning tree is constructed on the network if eagerly select and add edges while all vertices "U" become leaves."G” It is said to be the lightest spreading tree”.

02

Step 2: Algorithm

Procedure for spreading light across a tree (G,w,E)

Input: Linear graphs G = (V,E) ; edge weights we;UCVWe;UV

Output: The tree with the shortest span

A graph G~=(V~,E~) such that

V~=V-U

E~={u,v:u,vV-Uu,v}

To go and get MST , use Kruskal's methodG~=T~:

/Make sure the tree is still alive. does not exist

if T~does not exist:

It is impossible to plant the lightest spanning tree.Consider an Edge set E~such that:

u,vE~:uUvU

When sorting the edge, loop on until vertex "U" is reached.

//weights for each : uU

//refer textbook for makeset()

Filter all edge weights using makeset(u). E~by w~e

/Continue in this loop until enough edges' weights are rising in sequence.u,vE in increasing order of weight:

/Verify that find(u) isn't really same as,

// find (v)

if find(u)find(v)):

//insert the edges inside tree

add edge u, v to T~

/To combine the u and v , call function union on u , v .

// v

union( u,v )

//Return the tree

returnT~

03

Singleton collection Holding Parameter

makeset()definition:

makeset() generates singleton collections holding all value of the parameter argument. Its meaning of makeset may be found on page 132 of something like the textbook () .

union()definition:

To join the sets involving two outcomes for passing arguments, utilize union(). This definition term union may be stated on page 133 of both the textbook () .

find()definition:

find() is often used to explore each combination to nodes on until necessary sets are found. The definition of discover may be found on page 132 of the textbook() .

Explanation:

While in thinnest spanning tree method described previously,• Construct the graph G~with the vertex V~ and edge E~.

• Obtain the minimal spanning tree for just a graph using the Kruskal's approach.G~.

• Where there is no minimal spanning tree, then thinnest spanning tree can indeed be built..

• Generate any edge collection inside the name of the smallest spanning tree if one exists E~.

• Using for each read all the vertices “U”.

• Using the function make set() sort the weight of the edges.

Using for loop read the order of weight in increasing order.

• Using if condition, check whether find of vertex“u” is not equal to find of vertex“v”.

• If the above condition is true, then add edges to the tree.

• Invoke the union() function by passing the vertex u and v.

• Otherwise, exit the loop.

Finally, return the constructed tree T~.

04

Conclusion

• Other than the edge set “ E”, the remaining complexity is similar to Kruskal’s algorithm. That is, the running time is OElogv.

• Then, construct the set “U”.

o For edge weight “e = (u,v)”. If find(u) is not equal to find(v) . Then, the edge “E” takes the running time of role="math" localid="1658922590785" OElogU.

o When deleting the node “U” from the optimal solution, then, the algorithm is still bounded the running time of OElogV.

Therefore, the total running time for light spanning tree algorithm is OElogV.

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

Consider an undirected graph G=(V,E)with nonnegative edge weights role="math" localid="1658915178951" we0. Suppose that you have computed a minimum spanning tree of G, and that you have also computed shortest paths to all nodes from a particular node role="math" localid="1658915296891" sV. Now suppose each edge weight is increased by 1: the new weights are w0e=we+1.

(a) Does the minimum spanning tree change? Give an example where it changes or prove it cannot change.

(b) Do the shortest paths change? Give an example where they change or prove they cannot change.

In this problem, we will develop a new algorithm for finding minimum spanning trees. It is based upon the following property:

Pick any cycle in the graph, and let e be the heaviest edge in that cycle. Then there is a minimum spanning tree that does not contain e.

(a) Prove this property carefully.

(b) Here is the new MST algorithm. The input is some undirected graph G=(V,E) (in adjacency list format) with edge weights {we}.sort the edges according to their weights for each edge eE, in decreasing order of we:

if e is part of a cycle of G:

G = G - e (that is, remove e from G )

return G , Prove that this algorithm is correct.

(c) On each iteration, the algorithm must check whether there is a cycle containing a specific edge . Give a linear-time algorithm for this task, and justify its correctness.

(d) What is the overall time taken by this algorithm, in terms of |E|? Explain your answer.

Ternary Huffman. Trimedia Disks Inc. has developed “ternary” hard disks. Each cell on a disk can now store values 0,1, or 2(instead of just 0 or 1). To take advantage of this new technology, provide a modified Huffman algorithm for compressing sequences of characters from an alphabet of size n, where the characters occur with known frequencies f1, f2,...., fn. Your algorithm should encode each character with a variable-length codeword over the values 0,1,2, such that no codeword is a prefix of another codeword and so as to obtain the maximum possible compression. Prove that your algorithm is correct

Design a linear-time algorithm for the following task.

Input: A connected, undirected graphG.

Question:Is there an edge you can remove fromGwhile still leavingGconnected?

Can you reduce the running time of your algorithm toO(V)?

Show that for any integer n that is a power of 2 , there is an instance of the set cover problem (Section 5.4) with the following properties:

  1. There are n elements in the base set.
  2. The optimal cover uses just two sets.
  3. The greedy algorithm picks at least log n sets.

Thus the approximation ratio we derived in the chapter is tight.

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