Chapter 5: Q4E (page 161)
Show that if an undirected graph with n vertices has k connected components, then it has at least n - k edges.
Short Answer
The undirected graph with n vertices has k connected components with least n - k edges.
Chapter 5: Q4E (page 161)
Show that if an undirected graph with n vertices has k connected components, then it has at least n - k edges.
The undirected graph with n vertices has k connected components with least n - k edges.
All the tools & learning materials you need for study success - in one app.
Get started for freeTernary A server has customers waiting to be served. The service time required by eachcustomer is known in advance: it is minutes for customer i. So if, for example, the customers are served in order of increasing i , then the customer has to wait minutes. We wish to minimize the total waiting time.
(time spent waiting by customer ).
Give an efficient algorithm for computing the optimal order in which to process the customers.
The basic intuition behind Huffman’s algorithm, that frequent blocks should have short encodings and infrequent blocks should have long encodings, is also at work in English, where typical words like I, you, is, and, to, from, and so on are short, and rarely used words like velociraptor are longer.
However, words like fire!, help!, and run! are short not because they are frequent, but perhaps because time is precious in situations where they are used.
To make things theoretical, suppose we have a file composed of m different words, with frequencies . Suppose also that for the word, the cost per bit of encoding is . Thus, if we find a prefix-free code where the word has a codeword of length , then the total cost of the encoding will be localid="1659078764835" .
Show how to modify Huffman’s algorithm to find the prefix-free encoding of minimum total cost.
Suppose you are given a weighted graph 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.
Suppose you implement the disjoint-sets data structure usingunion-by-rank but not path compression. Give a sequence of union and find operations onelements that take time.
Consider an undirected graph with nonnegative edge weights role="math" localid="1658915178951" . 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" . Now suppose each edge weight is increased by 1: the new weights are .
(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.
What do you think about this solution?
We value your feedback to improve our textbook solutions.