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

Give You are given a graphG=(V,E)with positive edge weights, and a minimum spanning tree T=(V,E)with respect to these weights; you may assume GandTare given as adjacency lists. Now suppose the weight of a particular edge eE'is modified fromw(e)to a new value w'(e). You wish to quickly update the minimum spanning tree T to reflect this change, without recomputing the entire tree from scratch. There are four cases. In each case give a linear-time algorithm for updating the tree.

(a) eE'and w'(e)>w(e) .

(b) role="math" localid="1658907878059" eE'and w'(e)>w(e) .

(c) role="math" localid="1658907882667" eE'and w'(e)>w(e) .

(d) role="math" localid="1658907887400" eE'and w'(e)>w(e) .

Short Answer

Expert verified

Use G and T as adjacency lists and if weight of special edge is change from old value w(e) to new value w'(e) faster update minimum spanning tree to reflect change.

Step by step solution

01

Minimum Spanning Tree:

A minimal spanning tree (MST as a minimum spanning tree) is a subgroup of something like a tree that has the shortest packets from the source to all of its vertex points. A graph G = (V,E) Some minimum spanning tree is shown, along with edge weights that are positive. T=(V,E) such as relation to all of these weights. Take a look at the clustering lists. Graph G and T are supplied. After this step suppose that a particular edge’s weight is altered from w(e) to w'(e) .

02

Update w(e) > w'(e) is answer for (a).

a).

Algorithm:

Input:

Graph: G = (V,E)

minimum spanning tree: T = (V,E)

Procedure is given as

Declare T and G as adjacency list

Declare e ,

if (e is in e )

Modify w(e)to w'=e.

Else If (e is not in [E])

Update w (e) > w'(e)

Explanation of the given equation is as follows:

Consider the minimum spanning tree when the weight of one edge eE'is decreased. Assume that e=(u,v) .Add edge e to T tree that will create a distinct cycle, that can be found applying breadth first search and not considering weights. And this will take OT=OV time. And remove the cycle's maximum weight edge OV.

In this way linear time algorithm for updating a tree when eE'and w(e) > w'(e) is given.

03

Update T with e∉E'and w'(e) < w (e) : 

(b).

Algorithm:

Input:

Graph: G = (V,E)

minimum spanning tree: T = (V,E)

Procedure is given as

Declare T and G as adjacency list

Declare e ,

if ( is in e )

Modify w(e) to w'(e) .

Else If (e is not in [E])

Making change w(e) to w'(e) .

Else If (e is not in [E])

Update w'(e)<w(e)<p=" ">

Update T with w'(e) .

End.

Explanation:

Take into account the MST while one of the edge's weights is increased, as well as the outcomes of a Kruskal method.eE. That outcome is just the same as when edge demand is higher and also the minimum value gets chosen by the algorithm. (This suggests that the edges' weights are distinct.) Whenever the tree is updated in this fashion, a linear time approach is used. eE and w(e) < w'(e) is given.

04

Prove e∉E and w'(e) < w(e) .

(c)

Algorithm:

Input:

Graph: G = (V,E)

minimum spanning tree: T = (V,E)

Procedure is given as

Declare T and G as adjacency list

Declare e ,

if ( is in e)

Update w'(e) <w (e) <p=" ">

Update Tu with w' = (e)

Update Tvwith w'(e)

end

Explanation:

Analyse how minimum spanning t until one of the edges is heavier than the other eE'. And it is increased Let e = (u,v) and just let the subtrees that were created by deleting them e be Tvand Tu. With BFS (breadth first search )(ignoring weights of edges) , It really is possible to detect whichever vertices are all in the localid="1658916013612" Tu and which are in Tv in time localid="1658917474694" OV+EAssume each node is marked with its membership.

Each edge is checked and edge e' with having one endpoint Tu and Tvhaving the other only are kept This is possible to be done in time OV . Then the complete runtime is OV+E. Whenever the tree is updated throughout this fashion, a linear time approach is used. eEand w(e) > w'(e) is given.

05

Step 5: Prove e∉E  and w'(e) >w (e)  .

(d).

Algorithm:

Input:

Graph: G = (V,E)

minimum spanning tree: T = (V,E)

Procedure is given as

Declare T and G as adjacency list

Declare e ,

wedge cost W ;

decrement

when (w - d ), new cost T'

If (e is in [E])

Update w'(e)<w(e)<p=" "style=" box-sizing-box;"></w(e)<>

Update Tu with w’(e) with T'

Update Tv with w’(e) with T'

End

Explanation:

Whenever one of the edge's weights changes, think about the MST. eE' is reduced. Assume that T is the tree, and W is the weight of the tree. Once the value of the edge gets reduced by d, their actual cost is ( W - d ). Describe the subtrees of T as Tu and Tv , when edge e is deleted. Assuming T somehow doesn't stay an MST, its edge e is required for any T' to continue an MST. But both Tu and Tv Otherwise, T may not even be basic to begin with if they weren't MSTs with each respective node sets. As a result, the weight Tv can’t be lesser ( W - d ). Whenever a tree is updated in this fashion, a linear time approach is used eE'and w(e) > w'(e) .

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

Suppose you implement the disjoint-sets data structure usingunion-by-rank but not path compression. Give a sequence ofm union and find operations onnelements that take Ω(mlogn)time.

Suppose you are given a weighted graph G=(V,E) with a distinguished vertex s and where all edge weights are positive and distinct. Is it possible for a tree of shortest paths from s and a minimum spanning tree in G to not share any edges? If so, give an example. If not, give a reason.

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

The following statements may or may not be correct, In each case, either prove it (if it is correct) or give a counter-example (if it isn’t correct). Always assume that the graph G=(V,E)is undirected. Do not assume that edge weights are distinct unless this is specifically stated.

  1. If a graph G has more than |V|-1edges, and there is a unique heaviest edge, then this edge cannot be part of a minimum spanning tree.
  2. If G has a cycle with a unique heaviest edge e, then e cannot be part of any MST.
  3. Let e be any edge of minimum weight in G. Then e must be part of some MST.
  4. If the lightest edge in a graph is unique, then it must be part of every MST.
  5. If e is part of some MST of G, then it must be a lightest edge across some cut of .
  6. If G has a cycle with a unique lightest edge e must be part of every MST.
  7. The shortest-path tree computed by Dijkstra’s algorithm is necessarily an MST.
  8. The shortest path between two nodes is necessarily part of some MST.
  9. Prim’s algorithm works correctly when there are negative edges.
  10. (For any r>0, define an r-path to be a path whose edges all have weight <r). If G contains an r-path from node s to t , then every MST of G must also contain an r-path from node s to node t.

A prefix-free encoding of a finite alphabet Γ assigns each symbol in Γ a binary codeword, such that no codeword is a prefix of another codeword. A prefix-free encoding is minimal if it is not possible to arrive at another prefix-free encoding (of the same symbols) by contracting some of the keywords. For instance, the encoding {0,101} is not minimal since the codeword 101 can be contracted to 1 while still maintaining the prefix-free property.

Show that a minimal prefix-free encoding can be represented by a full binary tree in which each leaf corresponds to a unique element of Γ, whose codeword is generated by the path from the root to that leaf (interpreting a left branch as 0 and a right branch as 1 ).

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