/*! 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} Q23E Sometimes we want light spanning... [FREE SOLUTION] | 91影视

91影视

Sometimes we want light spanning trees with certain special properties. Here鈥檚 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鈥檛 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 鈥淯鈥.

鈥 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鈥渦鈥 is not equal to find of vertex鈥渧鈥.

鈥 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鈥檚 algorithm. That is, the running time is OElogv.

鈥 Then, construct the set 鈥淯鈥.

o For edge weight 鈥渆 = (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 鈥淯鈥 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 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

Ternary Huffman. Trimedia Disks Inc. has developed 鈥渢ernary鈥 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

A binary counter of unspecified length supports two operations: increment (which increases its value by one) and reset (which sets its value back to zero). Show that, starting from an initially zero counter, any sequence of n increment and reset operations takes time O(n); that is, the amortized time per operation is O(1) .

Prove the following two properties of the Huffman encoding scheme.

(a) If some character occurs with frequency more than 25, then there is guaranteed to be a codeword of length 1 .

(b) If all characters occur with frequency less than13 , then there is guaranteed to be no codeword of length 1 .

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.

The following table gives the frequencies of the letters of the English language (including the blank for separating words) in a particular corpus.

blank

18.3%

r

4.8%

y

1.6%

e

10.2%

d

3.5%

p

1.6%

t

7.7%

l

3.4%

b

1.3%

a

6.8%

c

2.6%

v

0.9%

o

5.9%

u

2.4%

k

0.6%

i

5.8%

m

2.1%

j

0.2%

n

5.5%

w

1.9%

x

0.2%

s

5.1%

f

1.8%

q

0.1%

h

4.9%

g

1.7%

z

0.1%

  1. What is the optimum Huffman encoding of this alphabet?
  2. What is the expected number of bits per letter?
  3. Suppose now that we calculate the entropy of these frequencies

H=t=026ptlog1pt

(see the box in page 143). Would you expect it to be larger or smaller than your answer above? Explain.

d. Do you think that this is the limit of how much English text can be compressed? What features of the English language, besides letters and their frequencies, should a better compression scheme take into account?

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.